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!
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
$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";
If the assignment of 0 to $num_rows is successful. So you have set $num_rows=0. = is assignment, == and === are comparison.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.