I have just inherited a PHP/MySQL
application which I am providing support for. I have tried to set up my local environment as close to the production environment, however somehow, the live code is managing to insert a row of data where the same code on my local setup is producing a warning and not performing the insert.
I have tried turning off MySQL Strict Mode
and running the query from PHP
directly against the database, and I found that the warnings were generated but the insert still worked.
What is preventing the insert from happening from code within PHP
in my local environment?
UPDATE (Include Example)
$sql="insert into table("name") values("12312341234")";
$result=mysql_query($sql);
if ($result) {
// do stuff
}
else {
$error = mysql_error();
data['error'] = $error;
}
The error message which is generated is
"Field 'filed_name' doesn't have a default value"
So basically, what is happening on the production server post query is a new row is appearing, however locally, there is nothing.
I will also mention, the else
clause is not even present on the production code. I have put it there to simply find out what is going on.