If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > update database with null variable

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-11-03, 09:53
jangofandango jangofandango is offline
Registered User
 
Join Date: Nov 2003
Posts: 1
update database with null variable

Hello,

I'm trying to update a mysql database with a variable $to. Depending on the value of $to, NULL or $to has to be entered.
Is there a way of updating the database with $to=NULL?

update(table set column = $to where...) with $to NULL or another value.

Hope you understand the question,

Thx for you advice!

jango
Reply With Quote
  #2 (permalink)  
Old 12-07-03, 17:39
ika ika is offline
Registered User
 
Join Date: Oct 2003
Location: Slovakia
Posts: 482
Re: update database with null variable

Quote:
Originally posted by jangofandango
Hello,

I'm trying to update a mysql database with a variable $to. Depending on the value of $to, NULL or $to has to be entered.
Is there a way of updating the database with $to=NULL?

update(table set column = $to where...) with $to NULL or another value.

Hope you understand the question,

Thx for you advice!

jango
Yes but you need to do:

mysql_query("update table table_name set column='.$to.' where ....");

if variable $to comes from post or get request then you need this before insert statement:

if(!$to || $to=="" || $to===NULL){
$to = "NULL"; //string
}

mysql_query.......
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On