Reputation: 127
I got "MySQL server gone away" error, i also got the resource id & connection also created successfully. Really don't know what's going wrong.
below is my code..
$query ='select * from table';
if (!@mysql_ping($conn)) {
conn = mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD) or die("Unable to connect with server");
mysql_select_db(DB_DATABASE,$conn) or die("Unable to select database");
mysql_query($query) or mysql_error($conn);
}
Any help? i miss something in or i need to set up some config file?
Upvotes: 0
Views: 186
Reputation: 607
if (!@mysql_ping($conn)) {
mysql_close($conn);
$conn = mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD) or die("Unable to connect with server");
echo 'connection created--' . $conn . '---<br/>';
mysql_select_db(DB_DATABASE, $conn) or die("Unable to select database" . mysql_error($conn));
}
Upvotes: 2