Hello, I am trying to create PHP code that will verify a number stored in a MySql Database. I keep getting the following error: Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\Studio\verify.php on line 24
fail
This is my code:
<?php
session_start();
$link = mysqli_connect('localhost','root','');
$database = mysqli_select_db($link, 'galaxy_studio');
$access = $_POST['cardnumber'];
if (isset($_POST["Verify"]))
{
if (empty ($access))
{
echo "<font color = 'red'> You must enter a crad number</font>";
}
}
else
{
$query = "SELECT * FROM galaxy_studio WHERE cardnumber = '". mysqli_real_escape_string($link,$access) ."'";
$result = mysqli_query($link,$query);
if (mysqli_num_rows($result) == 1)
{
echo "pass"; //Pass, do something
}
else
{
echo "fail"; //Fail
}
}
session_write_close();
?>