I've spent the whole day trying to set up development environment using:
- PHP Version 5.3.3
- apache 2.2
- mySQL Server 5.1
- Windows 7
The localhost renders the php fine, and I can work with mySQL via the command line client, but whenever I try to interact with mySQL through PHP I get a 30 second "waiting for localhost" and then a blank white browser.
- I've tried running tests scripts that just connect to the database.
- I've tried loggin-in via phpMyAdmin using 'root' and the correct password.
- The mySQL service IS running.
- No entries in the server error-log associated with the failed connection.
- I have the line "extension=php_mysql.dll" in my php.ini file and when I run "phpinfo()" all the mySQL information shows up.
- ".../php" and ".../MySQL Server 5.1/bin" are included in my PATH.
I basically followed the instructions here to set the whole thing up. I've tried everything I can think of twice so any fresh ideas would be greatly appreciated.
This is the code I'm using to connect to the database:
<?php
# Define MySQL Settings
define("MYSQL_HOST", "localhost");
define("MYSQL_USER", "root");
define("MYSQL_PASS", "devpass");
define("MYSQL_DB", "test");
$conn = mysql_connect("".MYSQL_HOST."", "".MYSQL_USER."", "".MYSQL_PASS."") or die(mysql_error());
mysql_select_db("".MYSQL_DB."",$conn) or die(mysql_error());
$sql = "SELECT * FROM test";
$res = mysql_query($sql);
while ($field = mysql_fetch_array($res))
{
$id = $field['id'];
$name = $field['name'];
echo 'ID: ' . $field['id'] . '<br />';
echo 'Name: ' . $field['name'] . '<br /><br />';
}
?>
It's strait out of the example from the link I posted. 'test' is a valid DB.