Following snippet is in my php-file, which figures as REST interface.
(...)
if ($stmt = $connection->prepare("INSERT INTO Resource VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)")){
$stmt->bind_param("sssssssii", $email, $timestamp, $title, $desc, $lat, $lng, $alt, $full, $cat);
// 1)
if($stmt->execute()){
// insertion of Resource successful
// 2)
}else{
// insertion of Resource failed
echo "INSERTION_RESOURCE_FAILED";
$stmt->close();
die;
}
(...)
The previous version, which was executed correctly, hadn't the two additional integer fields as parameters. I "debugged" the php file by placing echos in there. At position 1) I received the echo back, at position 2) not. That means to me that the stmt->execute() fails. But if that fails, why I don't receive the echo of the else block neither? How can I better debug such issues? Note that I checked the POST values, they are correct.
I also declared
error_reporting(E_ALL);
right after <?php
, and
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
after each set of query. Still, no error is echoed back. What could be the problem? ~
UPDATE
Like Linus mentioned, it was the missing display_errors()
. So finally I found out that it was a issue with a foreign key. But thanks to your answer I am finally able to debug the php some pleasenter!