Author

Topic: PHP help? (Read 305 times)

legendary
Activity: 2324
Merit: 1267
In Memory of Zepher
January 20, 2016, 06:00:59 PM
#3
If it's returning as a boolean it probably means that it is returning false meaning that there is either an error in your database connection or the query you are trying to do. Try doing echo mysqli_error($conn); and see if it returns anything that may help you figure out the problem.
You should probably implement some sort of error reporting to your script next time, something as simple as this would probably suffice:
Code:
if(!$result){
     die(mysqli_error($conn));
}

You should also be using Prepared Statements to secure your app if you do any MySQLi queries with user input, but that is another matter for another time.
newbie
Activity: 16
Merit: 0
January 20, 2016, 12:10:50 PM
#2
$result variable is not mysql resource, mean there is an error with the query or you are not connected to a database \ server.

did you use mysqli_connect() function bebore in your code?

to troubleshoot the error try

adding before your line 7 next code:
var_dump($con);
member
Activity: 112
Merit: 10
January 20, 2016, 02:11:06 AM
#1
I wasn't sure where to put this, I need some help.
bitcointap.xyz
I'm running my script on it, but it won't work for some reason. I sign up & try to login, it says the user does not exist.

Error at the top of the page:
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/.... on line 8
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /home/..../login.php on line 23

line 8:
Code:
$result = mysqli_query($con, "SELECT * FROM `settings`");
$settings = mysqli_fetch_array($result);
$result = : Line 7
$settings = : Line 8

line 23:
Blank.
line 22 & 24 (line 23 in the middle):
Code:
$result = mysqli_query($con, $sql);

$num = mysqli_num_rows($result);

Any help is REALLY appreciated. Thank you
Jump to: