Strange error using mysqli

Im trying to get a handle on mysqli, heres my code

<?php include "db/conn.php"; ?>
<h1>Assignment 3</h1>
<h2>Which employees have either a first name or a last name that begins with the letter S?</h2>
<?php
$query = "SELECT `LastNane`.`FirstName` FROM employees WHERE `FirstName` LIKE 'S%' OR `LastName` LIKE 'S%'";

$result = mysqli_query($conn,$query);
    echo "<table border='0'><tr><th>First Name</th><th>Last Name</th></tr>";

if (mysqli_num_rows($result) > 0) {
    // output data of each row
    while($row = mysqli_fetch_assoc($result))   {
  echo "<tr>";
  echo "<td>" . $row['FirstName'] . "</td>";
  echo "<td>" . $row['LastName'] . "</td>";
  echo "</tr>";
  	}
} else {
	echo "<tr><td colspan='2'>0 results</td></tr>";
}
echo "</table>";

mysqli_close($conn);
?> 
```
Heres my result

Assignment 3

Which employees have either a first name or a last name that begins with the letter S?

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /hermes/walnaweb10a/b2054/moo.teamluke/ajax/1.php on line 18
First Name	Last Name
0 results
.
Isnt everything set up correctly/

oh, had some syntax errors in my query

Yes, that’s usually a pointer that your query hasn’t worked for some reason, and returned false instead of a result set.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.