How does one refer to empty cells in mysql?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
drayarms
Forum Contributor
Posts: 134
Joined: Fri Dec 31, 2010 5:11 pm

How does one refer to empty cells in mysql?

Post by drayarms »

I have tried the following variations but non works

if($row['relation'] = "" ){

if($row['relation'] = '' ){

if($row['relation'] = NULL ){

if($row['relation'] IS NULL ){

if(strlen($row['relation']) = 0 ){

So how would one refer to a cell that is empty?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How does one refer to empty cells in mysql?

Post by Celauran »

The first mistake that I see is that you are using assignment operators ( = ) instead of comparison operators ( == ). Additionally, if you want to see what a variable contains, why not use var_dump()?
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: How does one refer to empty cells in mysql?

Post by fugix »

if($row['relation'] == "" ){

will work
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: How does one refer to empty cells in mysql?

Post by califdon »

if(empty($row['relation'])) {
Post Reply