954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Using php to check for empty fields in mysql table

Hello, anyone has an idea of how to use php to check to see if a field in a mysql table is empty or has no values?
i tried this
$query="SELECT fieldId FROM table WHERE fieldName IS NULL" ;
but this works only if the field in the table has been set to allow nulls. the problem is, i want to check also for empty field values (e.g. zero-length strings), which is not the same as NULL.
Thanks.

rinkarto
Newbie Poster
3 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

try:

$query="SELECT fieldId FROM table WHERE (fieldName IS NULL) OR (''=trim(fieldName) )";
hielo
Veteran Poster
1,124 posts since Dec 2007
Reputation Points: 116
Solved Threads: 244
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: