Jump to content

[SOLVED] mysqli error


PC Nerd

Recommended Posts

hey guys,

 

this is prpbably a stupid error that im overlooking, but im receiving the following error:

 

Fatal error: Function name must be a string in C:\xampp\xampp\xampp\htdocs\Battle-Ages\B_A-Attack.php on line 115

 

 

this only happens when i put in the error message by php ( ie WARNING .....) but i still get the ERRO 9 coming up when i dont, so either way there is an error.

this is my code

 

 

 

else {
$start_page = $_GET['page'];
}

$lower_page_num = $start_page * 20;
$higher_page_num = ($start_page + 1) * 20;

$curr_page_SQL = "SELECT User_Name, Points, Rank, Resource_1 FROM General_Stats WHERE Rank > ".$lower_page_num." AND < ".$higher_page_num." ORDER BY Rank DESC";
$curr_page_query = mysqli_query($DB_Server, $curr_page_SQL);
if(empty($curr_page_query)) {
die("ERROR 9 There wat an error in collecting the page information from the database. Please try again later.".$mysqli_error($curr_page_query));
}

###
### Display the table of results
###

.......

 

and there is one hell of a lot more blow and above.

 

now that code starts from line 105 ( the else)

 

and ends on line 120 ( the second ###)

 

 

thanks for your help

 

PC Nerd

Link to comment
https://forums.phpfreaks.com/topic/37002-solved-mysqli-error/
Share on other sites

tanx, that sorta helped, but wasnt very clear.

 

this is what i get now

 

 

 

Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in C:\xampp\xampp\xampp\htdocs\Battle-Ages\B_A-Attack.php on line 115

ERROR 9 There wat an error in collecting the page information from the database. Please try again later.\

 

 

any more suggestions???

 

Link to comment
https://forums.phpfreaks.com/topic/37002-solved-mysqli-error/#findComment-176616
Share on other sites

Change

$curr_page_query = mysqli_query($DB_Server, $curr_page_SQL);

if(empty($curr_page_query)) {

die("ERROR 9 There wat an error in collecting the page information from the database. Please try again later.".$mysqli_error($curr_page_query));

}

 

To:

 

$curr_page_query = mysqli_query($DB_Server, $curr_page_SQL) or die("Query died: ".mysqli_error($curr_page_query)";

 

Then have something like if(mysqli_num_rows($curr_page_query) < 1) { die("ERROR 9 There was an error in collecting the page information from the database. Please try again later.");

Link to comment
https://forums.phpfreaks.com/topic/37002-solved-mysqli-error/#findComment-176618
Share on other sites

or just change it from mysqli_error($cur_page_query) to mysqli_error($cur_page_SQL)

 

the error is pulled from the actual query ($cur_page_SQL) not the string that runs the query ($cur_page_query)

 

you can also just do mysqli_error() but that will only return the error from the latest query run.

Link to comment
https://forums.phpfreaks.com/topic/37002-solved-mysqli-error/#findComment-176622
Share on other sites

ok code is

 

 

 

 

else {
$start_page = $_GET['page'];
}

$lower_page_num = $start_page * 20;
$higher_page_num = ($start_page + 1) * 20;

$curr_page_SQL = "SELECT User_Name, Points, Rank, Resource_1 FROM General_Stats WHERE Rank > ".$lower_page_num." AND < ".$higher_page_num." ORDER BY Rank DESC";
#$curr_page_query = mysqli_query($DB_Server, $curr_page_SQL);
#if(empty($curr_page_query)) {
#	die("ERROR 9 There wat an error in collecting the page information from the database. Please try again later.".mysqli_error($curr_page_SQL));
#}



$curr_page_query = mysqli_query($DB_Server, $curr_page_SQL) or die("Query died: ".mysqli_error($curr_page_query));

if(mysqli_num_rows($curr_page_query) < 1) {
die("ERROR 9 There was an error in collecting the page information from the database. Please try again later.");
}

 

 

and the error is

 

 

 

Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in C:\xampp\xampp\xampp\htdocs\Battle-Ages\B_A-Attack.php on line 120

Query died:

 

 

ive never come across query died before, what does it mean and how do i fix it

 

 

Link to comment
https://forums.phpfreaks.com/topic/37002-solved-mysqli-error/#findComment-176639
Share on other sites

its from the require file at the top of my sfript ( not shown on this post.) i include it qhenever i need to connect to a database so all i have to do on the page is to include it and send sql queries, not connecgt all the time

 

 

 

its code is:

 

 

<?php


$host="localhost";
$account="root";
$password="PASSWORD";
$dbname="battle-ages_db";
$Error_Log[1] = "";
$Error_Log[2] = "";




$DB_Server = mysqli_connect($host, $account, $password);

if(empty($DB_Server)){
die("There was an error in connecting to the database.  Please try again later");}


$DB = mysqli_select_db($DB_Server, $dbname);

if(empty($DB)){
die("There was an erro in selecting the database.  Pleae try again later.");}
?>

 

 

its called Database_link.inc

 

 

 

thankx

 

Link to comment
https://forums.phpfreaks.com/topic/37002-solved-mysqli-error/#findComment-176643
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.