Bitcoin Forum
May 25, 2024, 06:06:55 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: PHP help?  (Read 305 times)
Robertt (OP)
Member
**
Offline Offline

Activity: 112
Merit: 10


View Profile
January 20, 2016, 06: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
tasoth
Newbie
*
Offline Offline

Activity: 16
Merit: 0


View Profile
January 20, 2016, 04: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);
minifrij
Legendary
*
Offline Offline

Activity: 2324
Merit: 1267


In Memory of Zepher


View Profile WWW
January 20, 2016, 10: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.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!