All pastes #161803 Raw Edit

mysql_num_rows issue

public php v1 · immutable
·published 2006-09-05 20:42 UTC
rendered paste body
The output of the following code is:SELECT now() as nowall is well$numrows=''no rows found<?php$db = mysql_connect('localhost', 'sierra');mysql_select_db('sierra', $db);$NumRows = 0;$sql = "SELECT now() as now";echo "<pre>$sql</pre>";$result = mysql_query($sql, $db) || die('query failed on line ' . __LINE__);if ($result) {  echo 'all is well<br>';} else {  echo 'MySQL Error ' . mysql_error();}$numrows = mysql_num_rows($result);echo "\$numrows='$numrows'<br>\n";if ($numrows > 0) {  $row = mysql_fetch_assoc($result);  $this->_PopulateValues($row);  echo "'" . $row['now'] . "'";} else {  echo 'no rows found';}?>