Bitcoin Forum

Other => Off-topic => Topic started by: Robertt on January 20, 2016, 06:11:06 AM



Title: PHP help?
Post by: Robertt on January 20, 2016, 06:11:06 AM
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


Title: Re: PHP help?
Post by: tasoth on January 20, 2016, 04:10:50 PM
$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);


Title: Re: PHP help?
Post by: minifrij on January 20, 2016, 10:00:59 PM
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 (http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) to secure your app if you do any MySQLi queries with user input, but that is another matter for another time.