Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2003
    Posts
    1

    Unanswered: 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

  2. #2
    Join Date
    Oct 2003
    Location
    Slovakia
    Posts
    482

    Re: update database with null variable

    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.......

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •