【发布时间】:2011-11-10 04:53:59
【问题描述】:
我正在尝试插入表格,但它不起作用。所以我告诉我的应用程序,如果你不能插入然后重定向到 home.php,它正在这样做。所以,某处肯定有错误。但是,它没有告诉我,有没有办法查看查询错误?代码如下:
if(0 === count($errors)){
// Sanitize name and phone number
$contact_name = mysql_real_escape_string($_POST['name']);
$phone_number = mysql_real_escape_string($_POST['phone_number']);
$query = "INSERT INTO `ani` (`ContactName`, `PhoneNumber`)
VALUES ('$contact_name', '$phone_number'";
$result = mysql_query($query);
if(mysql_errno() === 0){
header("Location: pinless.php");
} else {
header("Location: home.php");
// Here I want to see what the heck is wrong with the above query
// instead of redirecting
}
}
【问题讨论】:
-
您应该接受答案,而不是在标题中添加“已解决”
-
@Uncle Tom,点击你喜欢的答案上的复选标记。它不会花费您任何费用。
标签: php mysql sql error-handling