У меня есть код, подобный этому, и намеренно сделаю ошибку запроса: delete_test. php.
<?php
.....
$id = 1;
$sql = "xSELECT * FROM tbl_1 WHERE 1 AND id =?"; // Adding and an x to make this error
$stmt = $mysqli->stmt_init();
if(!$stmt->prepare($sql)){ // Line 56
echo "There is something wrong #1";
exit();
}else{
$stmt->bind_param("i", $id);
if(!$stmt->execute()){
echo "There is something wrong #2";
exit();
}
.....
}
.....
?>
Когда я запускаю delete_test. php я получаю эту ошибку:
Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'xSELECT * FROM tbl_1 WHERE 1 AND id =?' at line 1 in C:\xampp\htdocs\delete_test.php:56 Stack trace: #0 C:\xampp\htdocs\delete_test.php(56): mysqli_stmt->prepare('xSELECT * FROM ...') #1 {main} thrown in C:\xampp\htdocs\delete_test.php on line 56
Вместо того, чтобы напечатать это:
There is something wrong #1
Почему php пренебрегает echo "There is something wrong #1";
, где ошибка строки в этой строке?
И как заставить echo "There is something wrong #1";
печататься где ошибка строки в этой строке?