Mamp phpMyAdmin 表查询
我遇到的问题是我的代码似乎是正确的,并且在查询或连接到我的数据库时没有收到错误。 “错误编号 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);
I am having an issue were my code appears to be correct and am getting no errors querying or connecting to my database. "ErrorNumber 0:..."
But when i check phpMyAdmin it clearly has not queried. I have check all of my titles and table names, database name and everything is fine. My query will just not run or insert. here is my code:
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
$dbc是什么?
它应该是
$dbc = mysql_connect(...)
来测试连接。what is $dbc ?
It should rather be
$dbc = mysql_connect(...)
to test the connection.