...

View Full Version : equality for null from mysql



Aonlan
03-05-2008, 03:13 AM
How do I make a condition when a certain field of a mysql database is null. I tried empty($row['population']), !isset($row['population']), and $row['population'] == null. All of them don't work.


$result = mysql_query('SELECT city FROM town WHERE city="New York"');
$row = mysql_fetch_array($result);



if (empty($row['population']))
{
.......
}

EDIT: Found there is something wrong with my query!

_Aerospace_Eng_
03-05-2008, 03:20 AM
Well what is wrong with your query? To see if its null you can do

if($row['population'] == NULL)

Inigoesdr
03-05-2008, 03:29 AM
Well what is wrong with your query?
Just a guess, but it might be that the field isn't selected. I wonder if that edit was intended to mean the OP solved it.

Aonlan
03-05-2008, 04:23 AM
Yup, I solved it.

The query did not select the field I want to check if it is null. But now I have another question. But I will put it in another thread.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum