我得到“MySQL服务器消失”错误,我也得到了资源ID&连接也成功创建。真的不知道出了什么问题。
下面是我的代码..
$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);
}
有任何帮助吗?我想念一些东西或者我需要设置一些配置文件?
答案 0 :(得分:2)
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));
}