MySQL Forums
Forum List  »  PHP

Re: How in PHP 5.2 insert NULL into MySQL 5.0 database with variable value?
Posted by: condor
Date: December 04, 2006 01:01AM

I'm found some errors in my code, so this construction is good:
<?php
$var = $var == "" ? "'" . $var . "'" : "NULL";
$sql = "INSERT INTO MyTable VALUES ('$id', $var)";
.
.
.
?>
Thank you very much.

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.