robert_gsfame Posted April 27, 2010 Share Posted April 27, 2010 If i insert a data in mysql with single quotes let say INSERT INTO TABLE1 (photo)VALUES('') and the other one with this INSERT INTO TABLE1 (photo)VALUES(NULL) Will there any problem when i call it let say if(empty($photo)){echo "No photo";}else{echo "<img src blablabla Will both of records give me the same result which is "No photo" In simple words, is double single quotes still read as empty?? thx Quote Link to comment Share on other sites More sharing options...
de.monkeyz Posted April 27, 2010 Share Posted April 27, 2010 Single quotes with no data inside them in PHP is an EMPTY string. empty() will return true for '' Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted April 27, 2010 Author Share Posted April 27, 2010 okay , i thought that i have to set everything to NULL...so that when i use it inside php, then they will still read it as empty..so then the problem is in mysql, as i try to do this WHERE folder='' and the other one with this WHERE folder IS NULL, different records will be displayed for those similar query..... Quote Link to comment Share on other sites More sharing options...
de.monkeyz Posted April 27, 2010 Share Posted April 27, 2010 A blank string and NULL are completely different. They both return true in empty() but they are different types. NULL has no data type. In MySQL you should either keep them all as NULL or all as a blank string. Using a blank string is easier to manage with PHP in my opinion Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.