PC Nerd Posted February 4, 2007 Share Posted February 4, 2007 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 Quote Link to comment Share on other sites More sharing options...
corbin Posted February 4, 2007 Share Posted February 4, 2007 Ummm my guess is someone you're creating a function and you're trying to make the first character non alpha... Or, a better guess is that it's $mysqli_error($curr_page_query) causing the error... Try mysqli_error($curr_page_query) Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted February 4, 2007 Author Share Posted February 4, 2007 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??? Quote Link to comment Share on other sites More sharing options...
corbin Posted February 4, 2007 Share Posted February 4, 2007 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."); Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted February 4, 2007 Share Posted February 4, 2007 well i never used mysqli but it says that parameter 1 ($DB_Serever) should be mysqli, not boolean. so i think (not sure) that your $DB_Server is set to either true or false. Quote Link to comment Share on other sites More sharing options...
yzerman Posted February 4, 2007 Share Posted February 4, 2007 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. Quote Link to comment Share on other sites More sharing options...
corbin Posted February 4, 2007 Share Posted February 4, 2007 Ooohhh my bad... I never use mysqli Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted February 4, 2007 Author Share Posted February 4, 2007 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 Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted February 4, 2007 Share Posted February 4, 2007 you have Query died: in your die statement after the mysqli_query. what is $DB_Server is it a boolean? or is it a string? Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted February 4, 2007 Author Share Posted February 4, 2007 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 Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted February 4, 2007 Author Share Posted February 4, 2007 i just relised that the error log array was from an earlier error reporting thingy but its irreleve=ant and isnt used so its just taking up space, Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted February 4, 2007 Author Share Posted February 4, 2007 any ideas???? Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted February 4, 2007 Author Share Posted February 4, 2007 ok i solved it. there was an error in the SQL ( well i actually got rid of the order by and averything around that) thanks anyway Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.