Jump to content

Checking to see if a value returned from the database is blank or not?


galvin

Recommended Posts

Probably a silly question, but say you have a value in a mysql database that (naturally) can be either be blank or have characters in it.

 

If in my PHP I am doing a check to see if that returned field from the database HAS or DOES NOT HAVE a value entered in it, what is the proper way to do it?

 

For example, you could do either of the following below (and I'm sure there are probably 10 other ways to do it as well).  Is one of these quicker/more efficient than the other? 

 

I  know it probably does not matter in the grand scheme of things because it's such a quick check either way, but if one way is more "proper" than the other, please let me know...

if ($mysqlvalue!=="") 
OR
if (strlen($mysqlvalue>0))
OR 

 

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.