我有一个问题,我的代码似乎是正确的,我没有得到错误的查询或连接到我的数据库。"ErrorNumber 0:...“但是当我检查phpMyAdmin时,它显然没有被查询。我已经检查了我所有的标题和表名,数据库名,一切正常。我的查询将不会运行或插入。下面是我的代码:
mysql_connect('localhost', 'root', 'root', 'aliendatabase');
if (!$dbc) {
die('Error connecting to MySQL server.' . mysql_error());
}
$query = "INSERT INTO aliens_abduction(first_name, last_name, when_it_happened, how_long, how_many, alien_description, what_they_did, fang_spotted, other, email)" .
"VALUES('$first_name', '$last_name', '$when_it_happened', '$how_long', '$how_many', '$alien_description', '$what_they_did', '$fang_spotted', '$other', '$email')";
mysql_query($query, $aliendatabase);
echo "error number" . mysql_errno() . ": " . mysql_error() . "\n";
echo 'Connected Successfully';
mysql_close($dbc);发布于 2011-02-16 22:39:21
什么是$dbc?
应该使用$dbc = mysql_connect(...)来测试连接。
https://stackoverflow.com/questions/5017639
复制相似问题