As far as i know you use the port 3306 when you want to connect to a MySql host, not to the port that you specify, in this case 3307, also, you don't need to specify this on your connection scripts. So, change it to 3306 or delete from your code.I don't think so. Here is my code. Its a very simple code just to see if I can ever establish a connection with my database:
function open_connection() { $host='localhost:3307'; $user='any'; $db='my_db'; $password='my_pass'; $conn=mysql_connect($host,$user,$password); mysql_create_db ($db,$conn); mysql_select_db($db); return $conn; }
If I call this function within my file I get the error:
Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server during query in
Also, add to your code the mysql_error() function to check when you lost the connection and verify that in first case you get connected to the server:
function open_connection() {
$host='localhost';
$user='any';
$db='my_db';
$password='my_pass';
$conn=mysql_connect($host,$user,$password);
if (!$conn) {
die('Could not connect: ' . mysql_error());
}
mysql_create_db ($db,$conn) or die('Could not connect: ' . mysql_error());
mysql_select_db($db);
return $conn;
}Another problem is that according to the PHP online manual the mysql_create_db() function is obsolete and recommends to use the mysql_query() function instead.
Best regards,




