mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in...

Hello all,

To explain my problem, I’m fairly new to PHP, so I’m not quite really sure of all big fancy programming techniques out there.

So, to put it shortly. I’m building a login page. While trying it out locally, everything was working fine. Then, when I put it online to test it, the following error was displayed :

“mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in…”

I’ve been searching on it for a while now, but I cannot seem to be able to find a satisfactory answer.

One possible answer was that nothing was given to the query string. I tried echoing my query to be sure that something was given, and it returned something as expected.

I’m not sure if it has to do with the fact that I’m coding in a procedural manner… if so, it’s because I’m not really comfortable with the object-oriented approach.

So here is my code.

"

<?php include("include/db_local.php"); if($_SERVER["REQUEST_METHOD"] == "POST"){ $sEmail= $_REQUEST['textemail']; $sPassword= $_REQUEST['textpassword']; $sEmail= stripslashes($sEmail); $sPassword= stripslashes($sPassword); $sEmail= mysql_real_escape_string($sEmail); $sPassword= mysql_real_escape_string($sPassword); $query = "SELECT * FROM 'Users' WHERE 'Email' = '{$sEmail}' AND 'Password' = '{$sPassword}' "; $result = mysqli_query($bd, $query); //no user found if (mysqli_num_rows($result) == 0) { echo "Wrong email and/or password."; } else{ //if the user is found, some data is put in Session variables $infoUser = mysqli_fetch_assoc($result); $_SESSION['FName'] = $infoUser['FName']; $_SESSION['Name'] = $infoUser['Name']; $_SESSION['Email'] = $infoUser['Email']; $_SESSION['Phone'] = $infoUser['Phone']; $_SESSION['idUser'] = $infoUser['idUsers']; } mysqli_close($bd); } ?> "

I’ll appreciate any help you can give. Thanks in advance.

it may be due to the query try adding a die command on the end

[php]
$query = "SELECT * FROM ‘Users’
WHERE ‘Email’ = ‘{$sEmail}’ AND ‘Password’ = ‘{$sPassword}’ ";
$result = mysqli_query($bd, $query)or die(mysql_error());
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service