Hello experts,
I'm having some difficults with the code that i have used from one of the PHP, MySQL books. As the error that appears is in bold on line 17, and the error that shows is listed below:
"Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\Testing PHP with MySQL uses online Tutorials\Testing_with_MySQL_Database.php on line 17"
<html>
<body>
<?php
//Open connection to MySQL server
$connection = mysql_connect('localhost','root') or die ('Unable to connect!');
// select database for use
mysql_select_db('movies') or die ('Unable to select database!');
// create and execute query
$query = 'SELECT * FROM movies';
$result = mysql_query($query)
or die ('Error in query: $query. ' . mysql_error());
// check if records were returned
if (mysql_num_rows(Sresult) > 0)
{
//Print HTML table
echo '<table width = 100% cellpadding=10 cellspacing=0 border=1>';
echo
'<tr><td><b>Customer ID/b</td><tr><td><b>Customer Full Name/b</td><tr><td><b>Date Of Birth/b</td>';
// iterate over record set
// print each field
while($row = mysql_fetch_row($result))
{
echo '<tr>';
echo '<td>' . $row[0] . '</td>';
echo '<td>' . $row[1] . '</td>';
echo '<td>' . $row[2] . '</td>';
echo '</tr>';
}
echo '</table>';
}
else
{
// print error message
echo 'No rows found!';
}
// once processing is complete
// free result set
mysql_free_result($result);
//close connection to MySQL server
mysql_close($connection);
?>
</body>
</html>
Please help,
Thanks,
Mitesh