Reputation: 16183
I have an insert:
$sql = 'INSERT into orders SET
fax_int_prefix = "'.$_SESSION['fax_int_prefix'].'",
fax_prefix = "'.$_SESSION['fax_prefix'].'",
fax_first = "'.$_SESSION['fax_first'].'",
fax_last = "'.$_SESSION['fax_last'];
The value of all of these fields is that they are blank right before the insert. Here is an example of one of them I echo'd out just before the insert:
$_SESSION[fax_prefix] =
For some reason it inserts the integer 0, instead of a blank value or null, as it should. Why is it inserting 0's instead of blank spaces into my DB?
Upvotes: 1
Views: 3068
Reputation: 36546
Check the structure of your table. It's possible that it is not of type char
or varchar
(or that it is and has a default value set to '0'). To do this you can use phpmyadmin, SQLyog or other MySql admin programs.
Edit: If you want to store integers, but have the option of no value then make sure the type is nullable. i.e.: column_name INT(n) DEFAULT NULL
Upvotes: 2
Reputation: 15989
Check the schema of your database. Most likely they are integer fields or such.
SHOW FIELDS FROM orders;
or
SHOW CREATE TABLE orders;
might help. Additionally just printing out a variable is no good check, rather use var_dump().
Upvotes: 0