Jump to content

if(empty()) simple question


robert_gsfame

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/199868-ifempty-simple-question/
Share on other sites

okay  :P, 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..... :confused:

 

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

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.