HI,
I have the below php code that i am attempting to use to search the database for a value that has been inputted in the form. This connects to the database and works fine but brings back no results. I found the following error:
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /var/www/vhosts/dylan.simplyms.com/httpdocs/Search-Call.php on line 18 0 results
<?php
ini_set('display_errors', 1); error_reporting(E_ALL);
$servername = "localhost";
$username = "Dylanc";
$password = "xxxx";
$dbname = "FirstAttempt";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT client_id, domain, comments FROM FirstAttempt";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo "Client ID: " . $row["client_id"]. " - Domain: " . $row["domain"]. "Comments:" . $row["comments"];
}
} else {
echo "0 results";
}
$conn->close();
?>
I am relatively new to php, does anyone have any ideas?