RE: [PHP-DB] insert NULL to mysql table.
Anders, I don't know the specific answer to the question you pose, but if you echo() out your db query before you send it to the db, you'll be able to see the query as it is going to be sent to the db. You can then use your MySQL syntax knowledge to find the error in the different query strings. I bet it'll be dead obvious to you if you give that a shot. Rich > -Original Message- > From: anders thoresson [mailto:[EMAIL PROTECTED] > Sent: Wednesday, July 02, 2003 9:30 AM > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP-DB] insert NULL to mysql table. > > > > UPDATE un_issue SET i_editor = null WHERE i_date = '$issue'" > > Thanks. But how come this works and sets i_editor to NULL > > "UPDATE un_issue SET i_editor = $editor WHERE i_date = \"$issue\"" > > but the following two gives me a sql-error "You have an > error in your SQL > syntax near 'WHERE i_date = ' at line 1" > > "UPDATE un_issue SET i_editor = $editor WHERE i_date = '$issue\'" > "UPDATE un_issue SET i_editor = $editor WHERE i_date = $issue" > > and the following sets i_editor to 0, not NULL > > "UPDATE un_issue SET i_editor = '$editor' WHERE i_date = '$issue'" > > for all queries $editor = NULL and $issue = 2003-08-15 > > -- > anders thoresson > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] insert NULL to mysql table.
UPDATE un_issue SET i_editor = null WHERE i_date = '$issue'" Thanks. But how come this works and sets i_editor to NULL "UPDATE un_issue SET i_editor = $editor WHERE i_date = \"$issue\"" but the following two gives me a sql-error "You have an error in your SQL syntax near 'WHERE i_date = ' at line 1" "UPDATE un_issue SET i_editor = $editor WHERE i_date = '$issue\'" "UPDATE un_issue SET i_editor = $editor WHERE i_date = $issue" and the following sets i_editor to 0, not NULL "UPDATE un_issue SET i_editor = '$editor' WHERE i_date = '$issue'" for all queries $editor = NULL and $issue = 2003-08-15 -- anders thoresson -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] insert NULL to mysql table.
how about \0. yours is a foward slash not an escape. though that may just be your post you can also use an unquoted NULL. hth jeff anders thoresson <[EMAIL PROTECTED]To: [EMAIL PROTECTED] .net>cc: Subject: [PHP-DB] insert NULL to mysql table. 07/02/2003 08:59 AM Hi, I've the query "UPDATE un_issue SET i_editor = '$editor' WHERE i_date = '$issue'" where $editor = "/0" but the inserted value in un_issue.i_editor becomes 0. un_issue is defined as follows: CREATE TABLE un_issue ( i_id INT PRIMARY KEY AUTO_INCREMENT NOT NULL, i_date DATE NOT NULL, UNIQUE (i_date), i_number INT, i_editor INT ); Isn't /0 the escapestring for NULL? -- anders thoresson -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php