Jump to content

zero and null


abs0lut

Recommended Posts

I have a form with a text field.  If a user types "0", I want to insert "0" into my mysql database.  If a user leaves the field blank, I want to insert NULL into the database. 

However, my code keeps inserting "0" into my database even when the field is left blank.

could you please help me?

 

you can use if statement like :

if ($_GET['txt1']=""){
       $sql="INSERT INTO db values (null)"
}
else
       $sql="INSERT INTO db values('".$_GET['txt1']."')

 

Link to comment
https://forums.phpfreaks.com/topic/119576-zero-and-null/#findComment-616188
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.