dimanche 20 mai 2018

PHP Throwing query error when connection is working

I have a few lines of PHP that is not working with Mysql. The connections are working but the query are giving me a some problems.

$con=mysqli_connect("localhost","$username","$password","$username");

if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$sql="SELECT * FROM `AUT` WHERE USERNAME='$user' AND PASSWORD='$pass'";
$result=mysqli_query($con, $sql);
$rowcount=mysqli_num_rows($result);  //line 21

if ($rowcount==1)
  {
    echo 'WELCOME';
    printf("Result set has %d rows.\n",$rowcount);
 }
ELSE
 {   
    echo'ERROR';
    printf("The Results is %d \n",$result);
}

The results I keep getting is: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /storage/ssd3/588/2634588/public_html/login.php on line 21

Can anyone help me?




Aucun commentaire:

Enregistrer un commentaire