Page 1 of 1

super-newbie variable question

Posted: Wed Jan 27, 2010 3:19 pm
by kevinwinters
I create a variable "$num_rows" and assign it to a record result from a mysql query - why can't I access that variable later? sorry if this is a real silly question

Code: Select all

 
$query="SELECT * FROM testable WHERE `NAME`='AVAILABLE'";
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);
// works here but not down below
echo "$num_rows Rows\n";
 
if ($num_rows = 0) {
    echo "<br><h2 style=\"color: #ff0000\">This set of is completly filled out</h2><br>";
}
// find out why this doesn't work 
 
echo "$num_rows". " left";
 
 
Thanks for any help

Re: super-newbie variable question

Posted: Wed Jan 27, 2010 3:29 pm
by AbraCadaver

Code: Select all

if ($num_rows = 0) {
If the assignment of 0 to $num_rows is successful. So you have set $num_rows=0. = is assignment, == and === are comparison.