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;
}
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!
php mysql facebook boolean
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.
add a comment |
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!
php mysql facebook boolean
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 themysqli
prepared statement feature to properly escape your SQL queries.
– tadman
Mar 15 '13 at 18:59
add a comment |
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!
php mysql facebook boolean
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
php mysql facebook boolean
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 themysqli
prepared statement feature to properly escape your SQL queries.
– tadman
Mar 15 '13 at 18:59
add a comment |
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 themysqli
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
add a comment |
1 Answer
1
active
oldest
votes
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
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
add a comment |
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
add a comment |
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
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
edited May 2 '18 at 19:21
answered Mar 15 '13 at 18:52
castiscastis
6,94433355
6,94433355
add a comment |
add a comment |
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