Null value checking

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
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

Null value checking

Post by mhouldridge »

Hi,

I am trying to do an if statement as follows to check for a null value within my table under column asset;

Code: Select all

$row2 = $row['asset']; //set $row2 value of $row asset
	if ($row2 == ""){
	}
	else{
	$querytwo = mysql_query("SELECT * FROM ip where asset = $row2"); // Query database with $row2 value
	$ip = mysql_fetch_array($querytwo); // get result from database and assign as $ip
	}
This is not working. Does anybody know how to check for a null value?
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

Post by mhouldridge »

Ive sorted it with;

Code: Select all

$row2 = $row['asset']; //set $row2 value of $row asset
	if ($row2 == ""){
	$ip['ip'] = "";
	}
	else{
	$querytwo = mysql_query("SELECT * FROM ip where asset = $row2"); // Query database with $row2 value
	$ip = mysql_fetch_array($querytwo); // get result from database and assign as $ip
	}
Post Reply