MySQL Forums
Forum List  »  PHP

Re: How in PHP 5.2 insert NULL into MySQL 5.0 database with variable value?
Posted by: Bob Field
Date: November 28, 2006 09:59AM

Try something like this:
<?php
  $var = $var == "" ? "'" . $var . "'" : "NULL";
  $sql = "INSERT INTO MyTable VALUES ('$id', $var)";
    .
    .
    .
?>

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.