PHP kills scripts on fatal errors. If this line fails:
$data = $mysqli->prepare("somequery");
PHP will not kill your script but $data
is set to false. The script will be killed upon the next line:
$data->execute();
With the following error:
Fatal error: Call to a member function execute() on a non-object in...
First of all, you need to enable error_reporting
so that you could be able to diagnose the problem (and perhaps figure out the solution) yourself. Secondly, as @meagar mentioned, check for return values of mysqli functions:
$data = $mysqli->prepare("somequery");
if($data === false) {
echo $mysqli->error;
// dying isn't the most graceful approach by the way
die();
}
if($data->execute() === false) {
echo $mysqli->error;
die();
}
Changing from mysql_* to mysqli has nothing to do with your issue. If you were using mysql_* you still need to check the return values from functions. A generic rule: never assume that your queries will always succeed.