When executing the code below, I am getting the error: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given. From my understanding this would imply that mysql_query is returning false meaning the query is failing but I am not sure why.. Any ideas?

<?php
include 'global.php';

$case=$_GET['case'];

$query=" SELECT * FROM cases WHERE case='$case'";
$result=mysql_query($query);
$num=mysql_num_rows($result);
mysql_close();

$i=0;
while ($i < $num) {
$first=mysql_result($result,$i,"sm_firstname");
$last=mysql_result($result,$i,"sm_lastname");
?>
Member Avatar for diafol

case is a keyword in mysql. place all table and field names within backticks, like:

SELECT * FROM `cases` WHERE `case` = '$case'

The backtick button is usually before the number 1 on your keyboard (depends on the type). My keyboard needs the ALT + backtick button, release ALT, then any other key to display it.

Thanks, the error is gone.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.