I use syntax like name varchar(20) NOT NULL in mysql..i have a big confusion over here.
typically does it mean that this field is mandatory?
but when i store a space in this field it accepts it.is it correct. its like while insert i say '".$_POST['name']."'. even if the name does not have any value query is executed.
can any1 just clarify me on this ?
is NULL and blank space same ?
I’m not going to explain NULL to you again, the others have done that.
When doing SQL with PHP, please, always try to use PDO.
Example
This says, if your $_POST is either not set, or empty, set the value of $name to NULL. Otherwise use $_POST[‘name’].
Now, when you bind $name in your prepared SQL statement, you will either have a strict NULL value or the string of the name.