I've moved a webserver from a Ubuntu machine to a Mac OS X machine, including the database. However, I am surprised to see that prepared statements that were working perfectly fine in the original server performing inserts no longer work.
The $stmt->execute();
does not return false, so everything seems to be ok, but I cannot
see the new data inserted into the database.
PHP error log shows no issue.
I checked the privileges and everything looks good.
Do prepared statements need to be enabled in some specific way? How can I check whether they are succeeding?
My connection to the server is done to localhost on the same machine.
[Edit] After enabling general log I can see:
tail -f /var/log/apache2/error_log_mysql
/usr/local/mysql/bin/mysqld, Version: 5.6.17-log (MySQL Community Server (GPL)). started
with:
Tcp port: 0 Unix socket: (null)
Time Id Command Argument
140526 13:36:28 3 Connect root@localhost on database
3 Prepare select * from `users` where email_addr=?
3 Execute select * from `users` where email_addr='daorejw@ijaod.com'
3 Close stmt
3 Quit
4 Connect root@localhost on database
4 Prepare insert into `users` (first_name,last_name,password,email_addr,country,zip_code,company_name) VALUES(?,?,?,?,?,?,?)
4 Quit
I am suspicious of the port being 0 and socket Null, as well as the fact that there doesn't seem to be an execute after the prepare. I do have execute() as far as the php is concerned, but interestingly enough it doesn't seem to show up after the prepare.
$sql="insert into `users` (first_name,last_name,password,email_addr,country,zip_code,company_name,a, t)
VALUES(?,?,?,?,?,?,?,0,?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param('ssssssss', $p_firstname,$p_lastname,$p_password_hash,$p_emailaddr,$p_countryname,$p_zcode,$p_companyname,$t);
$stmt->execute();
if($stmt == false)
{
error_log("SQL Failed", 0);
die('Error: ' . mysqli_error($conn));
echo "Error adding record</br>";
}
else
{
// This part executes successfully.
}