mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in [duplicate]





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







34
















This question already has an answer here:




  • mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc… expects parameter 1 to be resource or result

    32 answers




I'm have some trouble checking if a Facebook User_id already exists in my database (if it doesn't it should then accept the user as a new one and else just load the canvas application). I ran it on my hosting server and there was no problem, but on my localhost it gives me the following error:



mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in


Here's my code:



<?
$fb_id = $user_profile['id'];
$locale = $user_profile['locale'];

if ($locale == "nl_NL") {
// Checking User Data @ WT-Database
$check1_task = "SELECT * FROM `users` WHERE `fb_id` = " . $fb_id . " LIMIT 0, 30 ";
$check1_res = mysqli_query($con, $check1_task);
$checken2 = mysqli_fetch_array($check1_res);
print $checken2;
// If the user does not exist @ WT-Database -> insert
if (!($checken2)) {
$add = "INSERT INTO users (fb_id, full_name, first_name, last_name, email) VALUES ('$fb_id', '$full_name', '$first_name', '$last_name', '$email')";
mysqli_query($con, $add);
}
// Double-check, the user won't be able to load the app on failure inserting to the database
if (!($checken2)) {
echo "Excuse us " . $first_name . ". Something went terribly wrong! Please try again later!";
exit;
}
} else {
include ('sorrylocale.html');
exit;
}


I've read it has something to do with my query being wrong, but it has worked on my hosting provider so that can't be it!










share|improve this question















marked as duplicate by John Conde, Tomasz Kowalczyk, hjpotter92, spajce, DarkAjax Mar 15 '13 at 23:27


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 3





    You need to add error handling for your queries so you can find out exactly why it is failing. You also have a significant SQL injection vulnerability.

    – Mike Brant
    Mar 15 '13 at 18:45






  • 2





    Please, please use the mysqli prepared statement feature to properly escape your SQL queries.

    – tadman
    Mar 15 '13 at 18:59


















34
















This question already has an answer here:




  • mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc… expects parameter 1 to be resource or result

    32 answers




I'm have some trouble checking if a Facebook User_id already exists in my database (if it doesn't it should then accept the user as a new one and else just load the canvas application). I ran it on my hosting server and there was no problem, but on my localhost it gives me the following error:



mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in


Here's my code:



<?
$fb_id = $user_profile['id'];
$locale = $user_profile['locale'];

if ($locale == "nl_NL") {
// Checking User Data @ WT-Database
$check1_task = "SELECT * FROM `users` WHERE `fb_id` = " . $fb_id . " LIMIT 0, 30 ";
$check1_res = mysqli_query($con, $check1_task);
$checken2 = mysqli_fetch_array($check1_res);
print $checken2;
// If the user does not exist @ WT-Database -> insert
if (!($checken2)) {
$add = "INSERT INTO users (fb_id, full_name, first_name, last_name, email) VALUES ('$fb_id', '$full_name', '$first_name', '$last_name', '$email')";
mysqli_query($con, $add);
}
// Double-check, the user won't be able to load the app on failure inserting to the database
if (!($checken2)) {
echo "Excuse us " . $first_name . ". Something went terribly wrong! Please try again later!";
exit;
}
} else {
include ('sorrylocale.html');
exit;
}


I've read it has something to do with my query being wrong, but it has worked on my hosting provider so that can't be it!










share|improve this question















marked as duplicate by John Conde, Tomasz Kowalczyk, hjpotter92, spajce, DarkAjax Mar 15 '13 at 23:27


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 3





    You need to add error handling for your queries so you can find out exactly why it is failing. You also have a significant SQL injection vulnerability.

    – Mike Brant
    Mar 15 '13 at 18:45






  • 2





    Please, please use the mysqli prepared statement feature to properly escape your SQL queries.

    – tadman
    Mar 15 '13 at 18:59














34












34








34


12







This question already has an answer here:




  • mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc… expects parameter 1 to be resource or result

    32 answers




I'm have some trouble checking if a Facebook User_id already exists in my database (if it doesn't it should then accept the user as a new one and else just load the canvas application). I ran it on my hosting server and there was no problem, but on my localhost it gives me the following error:



mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in


Here's my code:



<?
$fb_id = $user_profile['id'];
$locale = $user_profile['locale'];

if ($locale == "nl_NL") {
// Checking User Data @ WT-Database
$check1_task = "SELECT * FROM `users` WHERE `fb_id` = " . $fb_id . " LIMIT 0, 30 ";
$check1_res = mysqli_query($con, $check1_task);
$checken2 = mysqli_fetch_array($check1_res);
print $checken2;
// If the user does not exist @ WT-Database -> insert
if (!($checken2)) {
$add = "INSERT INTO users (fb_id, full_name, first_name, last_name, email) VALUES ('$fb_id', '$full_name', '$first_name', '$last_name', '$email')";
mysqli_query($con, $add);
}
// Double-check, the user won't be able to load the app on failure inserting to the database
if (!($checken2)) {
echo "Excuse us " . $first_name . ". Something went terribly wrong! Please try again later!";
exit;
}
} else {
include ('sorrylocale.html');
exit;
}


I've read it has something to do with my query being wrong, but it has worked on my hosting provider so that can't be it!










share|improve this question

















This question already has an answer here:




  • mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc… expects parameter 1 to be resource or result

    32 answers




I'm have some trouble checking if a Facebook User_id already exists in my database (if it doesn't it should then accept the user as a new one and else just load the canvas application). I ran it on my hosting server and there was no problem, but on my localhost it gives me the following error:



mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in


Here's my code:



<?
$fb_id = $user_profile['id'];
$locale = $user_profile['locale'];

if ($locale == "nl_NL") {
// Checking User Data @ WT-Database
$check1_task = "SELECT * FROM `users` WHERE `fb_id` = " . $fb_id . " LIMIT 0, 30 ";
$check1_res = mysqli_query($con, $check1_task);
$checken2 = mysqli_fetch_array($check1_res);
print $checken2;
// If the user does not exist @ WT-Database -> insert
if (!($checken2)) {
$add = "INSERT INTO users (fb_id, full_name, first_name, last_name, email) VALUES ('$fb_id', '$full_name', '$first_name', '$last_name', '$email')";
mysqli_query($con, $add);
}
// Double-check, the user won't be able to load the app on failure inserting to the database
if (!($checken2)) {
echo "Excuse us " . $first_name . ". Something went terribly wrong! Please try again later!";
exit;
}
} else {
include ('sorrylocale.html');
exit;
}


I've read it has something to do with my query being wrong, but it has worked on my hosting provider so that can't be it!





This question already has an answer here:




  • mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc… expects parameter 1 to be resource or result

    32 answers








php mysql facebook boolean






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 2 '18 at 0:15









Peter Mortensen

13.9k1987113




13.9k1987113










asked Mar 15 '13 at 18:43









Mats de SwartMats de Swart

195139




195139




marked as duplicate by John Conde, Tomasz Kowalczyk, hjpotter92, spajce, DarkAjax Mar 15 '13 at 23:27


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by John Conde, Tomasz Kowalczyk, hjpotter92, spajce, DarkAjax Mar 15 '13 at 23:27


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 3





    You need to add error handling for your queries so you can find out exactly why it is failing. You also have a significant SQL injection vulnerability.

    – Mike Brant
    Mar 15 '13 at 18:45






  • 2





    Please, please use the mysqli prepared statement feature to properly escape your SQL queries.

    – tadman
    Mar 15 '13 at 18:59














  • 3





    You need to add error handling for your queries so you can find out exactly why it is failing. You also have a significant SQL injection vulnerability.

    – Mike Brant
    Mar 15 '13 at 18:45






  • 2





    Please, please use the mysqli prepared statement feature to properly escape your SQL queries.

    – tadman
    Mar 15 '13 at 18:59








3




3





You need to add error handling for your queries so you can find out exactly why it is failing. You also have a significant SQL injection vulnerability.

– Mike Brant
Mar 15 '13 at 18:45





You need to add error handling for your queries so you can find out exactly why it is failing. You also have a significant SQL injection vulnerability.

– Mike Brant
Mar 15 '13 at 18:45




2




2





Please, please use the mysqli prepared statement feature to properly escape your SQL queries.

– tadman
Mar 15 '13 at 18:59





Please, please use the mysqli prepared statement feature to properly escape your SQL queries.

– tadman
Mar 15 '13 at 18:59












1 Answer
1






active

oldest

votes


















90














That query is failing and returning false.



Put this after mysqli_query() to see what's going on.



if (!$check1_res) {
printf("Error: %sn", mysqli_error($con));
exit();
}


For more information:



http://www.php.net/manual/en/mysqli.error.php






share|improve this answer
































    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    90














    That query is failing and returning false.



    Put this after mysqli_query() to see what's going on.



    if (!$check1_res) {
    printf("Error: %sn", mysqli_error($con));
    exit();
    }


    For more information:



    http://www.php.net/manual/en/mysqli.error.php






    share|improve this answer






























      90














      That query is failing and returning false.



      Put this after mysqli_query() to see what's going on.



      if (!$check1_res) {
      printf("Error: %sn", mysqli_error($con));
      exit();
      }


      For more information:



      http://www.php.net/manual/en/mysqli.error.php






      share|improve this answer




























        90












        90








        90







        That query is failing and returning false.



        Put this after mysqli_query() to see what's going on.



        if (!$check1_res) {
        printf("Error: %sn", mysqli_error($con));
        exit();
        }


        For more information:



        http://www.php.net/manual/en/mysqli.error.php






        share|improve this answer















        That query is failing and returning false.



        Put this after mysqli_query() to see what's going on.



        if (!$check1_res) {
        printf("Error: %sn", mysqli_error($con));
        exit();
        }


        For more information:



        http://www.php.net/manual/en/mysqli.error.php







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited May 2 '18 at 19:21

























        answered Mar 15 '13 at 18:52









        castiscastis

        6,94433355




        6,94433355

















            這個網誌中的熱門文章

            Tangent Lines Diagram Along Smooth Curve

            Yusuf al-Mu'taman ibn Hud

            Zucchini