Php 如何查看MySQL查询错误详细信息?
我正试图插入到表中,但它不起作用。所以我告诉我的应用程序,如果不能插入,就重定向到home.php,它正在这样做。所以,这里肯定有错误。但是,它没有告诉我,有没有办法看到查询错误?代码如下:Php 如何查看MySQL查询错误详细信息?,php,mysql,sql,error-handling,Php,Mysql,Sql,Error Handling,我正试图插入到表中,但它不起作用。所以我告诉我的应用程序,如果不能插入,就重定向到home.php,它正在这样做。所以,这里肯定有错误。但是,它没有告诉我,有没有办法看到查询错误?代码如下: if(0 === count($errors)){ // Sanitize name and phone number $contact_name = mysql_real_escape_string($_POST['name']); $phone_number = mysql_real_esca
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
}
}
是的<代码>不要惊慌是你应该做的。是的<代码>不要惊慌是您应该做的。您应该接受answer@Uncle汤姆,点击你喜欢的答案上的复选标记。它不会花费你任何东西。与其在标题中添加“已解决”,不如接受answer@Uncle汤姆,点击你喜欢的答案上的复选标记。它不花你任何钱。
echo mysql_error();
echo mysql_errno();
echo mysql_error();