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
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:

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.