Re: Inserting null values in mysql with PHP
My apologies.. I scanned back looking for the reference but couldn't find it... I thought it worth reiterating what turned out to be your point because there seems to be so much confusion around this issue. - michael On 8/9/07, Brent Baisley <[EMAIL PROTECTED]> wrote: > Actually, I said to make sure you are NOT quoting it. The advice > wasn't to add quotes. > > On Aug 9, 2007, at 2:27 PM, Michael Dykman wrote: > > > IF it is a null in that column, you should not see the word 'null'.. > > and the advise to put quotes around it I read earlier in this thread > > is completely misguided.. If you insert the string 'null' or 'NULL' > > into the database, you have just strored a string.. > > > > Perhaps it is the form of your queries: NULL needs special handling. > > YOu cant say > > SELECT * FROM foo WHERE bar = null; > > > > you need to specify: > > SELECT * FROM foo WHERE bar IS NULL; > > > > Nothing ever 'equals' NULL in SQL not even another NULL.. > > > > - michael > > > > > > On 8/9/07, Mahmoud Badreddine <[EMAIL PROTECTED]> wrote: > >> I did remove that column from the insert statement and no text > >> appeared at > >> all in that field under that column. Not even the word "NULL". > >> > >> On 8/8/07, Christian High <[EMAIL PROTECTED]> wrote: > >>> > >>> On 8/8/07, Brent Baisley <[EMAIL PROTECTED]> wrote: > One thing to check is to make sure you are not quoting your NULL > value for your insert statement. MySQL will try to convert that > to a > numeric value, which may end up as 0. > > On Aug 8, 2007, at 12:55 PM, Mahmoud Badreddine wrote: > > > Hello > > I have a table which contain a few numerical values. > > I set the default values to be NULL. > > When I insert values using phpMyAdmin, it sets the values to NULL > > correctly. > > But when I insert using a PHP script that I wrote it sets the > > values > > to 0.00or 0. > > In my script I do test if the values are empty and in case they > > are > > I set > > the variable to NULL. But that still doesn't help. > > Is that a mysql problem ? > > Thank you. > > > > -- > > -Mahmoud Badreddine > > > > http://www.spreadfirefox.com/ > > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe:http://lists.mysql.com/mysql? > [EMAIL PROTECTED] > > > >>> As long as you are testing to see if they should be null, and the > >>> default is set to null, you could exclude the column all together > >>> from > >>> the insert statement and you should see they are then recorded in > >>> the > >>> table as null. > >>> > >>> cj > >>> > >> > >> > >> > >> -- > >> -Mahmoud Badreddine > >> > >> http://www.spreadfirefox.com/ > >> > > > > > > -- > > - michael dykman > > - [EMAIL PROTECTED] > > > > - All models are wrong. Some models are useful. > > -- - michael dykman - [EMAIL PROTECTED] - All models are wrong. Some models are useful. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Inserting null values in mysql with PHP
IF it is a null in that column, you should not see the word 'null'.. and the advise to put quotes around it I read earlier in this thread is completely misguided.. If you insert the string 'null' or 'NULL' into the database, you have just strored a string.. Perhaps it is the form of your queries: NULL needs special handling. YOu cant say SELECT * FROM foo WHERE bar = null; you need to specify: SELECT * FROM foo WHERE bar IS NULL; Nothing ever 'equals' NULL in SQL not even another NULL.. - michael On 8/9/07, Mahmoud Badreddine <[EMAIL PROTECTED]> wrote: > I did remove that column from the insert statement and no text appeared at > all in that field under that column. Not even the word "NULL". > > On 8/8/07, Christian High <[EMAIL PROTECTED]> wrote: > > > > On 8/8/07, Brent Baisley <[EMAIL PROTECTED]> wrote: > > > One thing to check is to make sure you are not quoting your NULL > > > value for your insert statement. MySQL will try to convert that to a > > > numeric value, which may end up as 0. > > > > > > On Aug 8, 2007, at 12:55 PM, Mahmoud Badreddine wrote: > > > > > > > Hello > > > > I have a table which contain a few numerical values. > > > > I set the default values to be NULL. > > > > When I insert values using phpMyAdmin, it sets the values to NULL > > > > correctly. > > > > But when I insert using a PHP script that I wrote it sets the values > > > > to 0.00or 0. > > > > In my script I do test if the values are empty and in case they are > > > > I set > > > > the variable to NULL. But that still doesn't help. > > > > Is that a mysql problem ? > > > > Thank you. > > > > > > > > -- > > > > -Mahmoud Badreddine > > > > > > > > http://www.spreadfirefox.com/ > > > > > > > > > -- > > > MySQL General Mailing List > > > For list archives: http://lists.mysql.com/mysql > > > To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] > > > > > > > > As long as you are testing to see if they should be null, and the > > default is set to null, you could exclude the column all together from > > the insert statement and you should see they are then recorded in the > > table as null. > > > > cj > > > > > > -- > -Mahmoud Badreddine > > http://www.spreadfirefox.com/ > -- - michael dykman - [EMAIL PROTECTED] - All models are wrong. Some models are useful. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Inserting null values in mysql with PHP
I did remove that column from the insert statement and no text appeared at all in that field under that column. Not even the word "NULL". On 8/8/07, Christian High <[EMAIL PROTECTED]> wrote: > > On 8/8/07, Brent Baisley <[EMAIL PROTECTED]> wrote: > > One thing to check is to make sure you are not quoting your NULL > > value for your insert statement. MySQL will try to convert that to a > > numeric value, which may end up as 0. > > > > On Aug 8, 2007, at 12:55 PM, Mahmoud Badreddine wrote: > > > > > Hello > > > I have a table which contain a few numerical values. > > > I set the default values to be NULL. > > > When I insert values using phpMyAdmin, it sets the values to NULL > > > correctly. > > > But when I insert using a PHP script that I wrote it sets the values > > > to 0.00or 0. > > > In my script I do test if the values are empty and in case they are > > > I set > > > the variable to NULL. But that still doesn't help. > > > Is that a mysql problem ? > > > Thank you. > > > > > > -- > > > -Mahmoud Badreddine > > > > > > http://www.spreadfirefox.com/ > > > > > > -- > > MySQL General Mailing List > > For list archives: http://lists.mysql.com/mysql > > To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] > > > > > As long as you are testing to see if they should be null, and the > default is set to null, you could exclude the column all together from > the insert statement and you should see they are then recorded in the > table as null. > > cj > -- -Mahmoud Badreddine http://www.spreadfirefox.com/
Re: Inserting null values in mysql with PHP
Hi I added the following statement at the end of the my.cnf file: sql-mode="STRICT_ALL_TABLES,ALLOW_INVALID_DATES" but I still got the values 0 and 0.00 where no values were entered. I did restart the the mysql daemon of course. What am I still doing wrong? Thanks. On 8/8/07, Christian High <[EMAIL PROTECTED]> wrote: > > On 8/8/07, Brent Baisley <[EMAIL PROTECTED]> wrote: > > One thing to check is to make sure you are not quoting your NULL > > value for your insert statement. MySQL will try to convert that to a > > numeric value, which may end up as 0. > > > > On Aug 8, 2007, at 12:55 PM, Mahmoud Badreddine wrote: > > > > > Hello > > > I have a table which contain a few numerical values. > > > I set the default values to be NULL. > > > When I insert values using phpMyAdmin, it sets the values to NULL > > > correctly. > > > But when I insert using a PHP script that I wrote it sets the values > > > to 0.00or 0. > > > In my script I do test if the values are empty and in case they are > > > I set > > > the variable to NULL. But that still doesn't help. > > > Is that a mysql problem ? > > > Thank you. > > > > > > -- > > > -Mahmoud Badreddine > > > > > > http://www.spreadfirefox.com/ > > > > > > -- > > MySQL General Mailing List > > For list archives: http://lists.mysql.com/mysql > > To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] > > > > > As long as you are testing to see if they should be null, and the > default is set to null, you could exclude the column all together from > the insert statement and you should see they are then recorded in the > table as null. > > cj > -- -Mahmoud Badreddine http://www.spreadfirefox.com/
Re: Inserting null values in mysql with PHP
On 8/8/07, Brent Baisley <[EMAIL PROTECTED]> wrote: > One thing to check is to make sure you are not quoting your NULL > value for your insert statement. MySQL will try to convert that to a > numeric value, which may end up as 0. > > On Aug 8, 2007, at 12:55 PM, Mahmoud Badreddine wrote: > > > Hello > > I have a table which contain a few numerical values. > > I set the default values to be NULL. > > When I insert values using phpMyAdmin, it sets the values to NULL > > correctly. > > But when I insert using a PHP script that I wrote it sets the values > > to 0.00or 0. > > In my script I do test if the values are empty and in case they are > > I set > > the variable to NULL. But that still doesn't help. > > Is that a mysql problem ? > > Thank you. > > > > -- > > -Mahmoud Badreddine > > > > http://www.spreadfirefox.com/ > > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] > > As long as you are testing to see if they should be null, and the default is set to null, you could exclude the column all together from the insert statement and you should see they are then recorded in the table as null. cj -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Inserting null values in mysql with PHP
One thing to check is to make sure you are not quoting your NULL value for your insert statement. MySQL will try to convert that to a numeric value, which may end up as 0. On Aug 8, 2007, at 12:55 PM, Mahmoud Badreddine wrote: Hello I have a table which contain a few numerical values. I set the default values to be NULL. When I insert values using phpMyAdmin, it sets the values to NULL correctly. But when I insert using a PHP script that I wrote it sets the values to 0.00or 0. In my script I do test if the values are empty and in case they are I set the variable to NULL. But that still doesn't help. Is that a mysql problem ? Thank you. -- -Mahmoud Badreddine http://www.spreadfirefox.com/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Inserting null values in mysql with PHP
That is MySQL, not PHP doing that to you. You need to set your SQL_MODE to strict to get that kind of behavior.. there are other implications to this mode so you should review: http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html - michael On 8/8/07, Mahmoud Badreddine <[EMAIL PROTECTED]> wrote: > Hello > I have a table which contain a few numerical values. > I set the default values to be NULL. > When I insert values using phpMyAdmin, it sets the values to NULL correctly. > But when I insert using a PHP script that I wrote it sets the values > to 0.00or 0. > In my script I do test if the values are empty and in case they are I set > the variable to NULL. But that still doesn't help. > Is that a mysql problem ? > Thank you. > > -- > -Mahmoud Badreddine > > http://www.spreadfirefox.com/ > -- - michael dykman - [EMAIL PROTECTED] - All models are wrong. Some models are useful. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Inserting null values in mysql with PHP
Hello I have a table which contain a few numerical values. I set the default values to be NULL. When I insert values using phpMyAdmin, it sets the values to NULL correctly. But when I insert using a PHP script that I wrote it sets the values to 0.00or 0. In my script I do test if the values are empty and in case they are I set the variable to NULL. But that still doesn't help. Is that a mysql problem ? Thank you. -- -Mahmoud Badreddine http://www.spreadfirefox.com/