PC Nerd Posted July 4, 2006 Share Posted July 4, 2006 hey guysim working on a login script and i have run into this error. i hav no idea what it means or where to start debugging. can anyone help me ???ERROR: Fatal error: Call to undefined function: mysqli_query() in [u]URL[/u] on line 44LINE 44 IS: $result = mysqli_query($User_SQL, $DB_Server);i am really stumpedi have defined the variables used here:$User_SQL = "SELECT User_Name, Password FROM Table_1 WHERE User_Name = '" . $_POST['User_Name'] . "'";$DB_Server = mysql_connect ($host, $account, $password);and the variable in those definitions are definately defined.all help will be much appreciatedPC Nerd Quote Link to comment https://forums.phpfreaks.com/topic/13633-mysqli_query-error/ Share on other sites More sharing options...
redarrow Posted July 4, 2006 Share Posted July 4, 2006 echo $User_Sql;echo the query out ok. Quote Link to comment https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-52855 Share on other sites More sharing options...
redarrow Posted July 4, 2006 Share Posted July 4, 2006 $result = mysql_query($User_SQL, $DB_Server);change to this ok Quote Link to comment https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-52856 Share on other sites More sharing options...
zawadi Posted July 4, 2006 Share Posted July 4, 2006 the error you are getting is due to mysql ether not being setup in PHP or that PHP is old and does not have MYSQL turned on. :( Quote Link to comment https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-52859 Share on other sites More sharing options...
Houdini Posted July 4, 2006 Share Posted July 4, 2006 You are using both mysql and mysqli, unless the server is PHP 5 mysqli will not work, so why do you have both? Apparently you do not have mysqli at all or it is not enabled, and with PHP 5 it is by default and mysql is disabled. show more of your code, you can't mix mysql and mysqli functions like that. Quote Link to comment https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-52861 Share on other sites More sharing options...
wildteen88 Posted July 4, 2006 Share Posted July 4, 2006 Use mysql_query as you dont have the mysqli extension enabled so you are getting the undefined error message with any mysqli related function. mysqli based functions are only available for PHP5+ the is configured to use the mysqli extension. If you are using PHP4 then you cannot use or enable any mysqli functions as they are not available for that version. If you wish to use the mysqli related functions then you'll want to upgrade PHP to version 5, or move to a different host that has PHP5 installed and is configured to use the mysqli extension. Quote Link to comment https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-52898 Share on other sites More sharing options...
PC Nerd Posted July 5, 2006 Author Share Posted July 5, 2006 im using php 4.4.2and mysql 4.1.19iis there any way to connect the two versions . if not does anyone know of other free servers that give 500MB and Mysql / PHP that will work to gether. im currently with http://addyour.net Quote Link to comment https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-53124 Share on other sites More sharing options...
trq Posted July 5, 2006 Share Posted July 5, 2006 As has already been said, use the mysql* functions, NOT mysqli* Quote Link to comment https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-53126 Share on other sites More sharing options...
PC Nerd Posted July 5, 2006 Author Share Posted July 5, 2006 ok, im still getting errors on the following lines. The following is the codeand the error message:[b]ERRORS[/b]Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/battle1a/public_html/game/B_A-Login.php on line 44Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/battle1a/public_html/game/B_A-Login.php on line 46[b]CODE[/b]$result = mysql_query($User_SQL, $DB_Server);$confirm = mysql_fetch_array($result); i am new to database connection and i appreciate all you help Quote Link to comment https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-53280 Share on other sites More sharing options...
wildteen88 Posted July 5, 2006 Share Posted July 5, 2006 Change:[code]$result = mysql_query($User_SQL, $DB_Server);[/code]to the following:[code]$result = mysql_query($User_SQL, $DB_Server) or die("Unable to perform query: {$User_SQL}<br />\n" . mysql_error());[/code]When you run your code again what do error do you get? Quote Link to comment https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-53282 Share on other sites More sharing options...
PC Nerd Posted July 5, 2006 Author Share Posted July 5, 2006 ive changed the line and have been given the following:ERRORWarning: mysql_query(): supplied argument is not a valid MySQL-Link resource in URL on line 44Unable to perform query: SELECT User_Name, Password FROM Table_1 WHERE User_Name = '' Quote Link to comment https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-53283 Share on other sites More sharing options...
Houdini Posted July 5, 2006 Share Posted July 5, 2006 Could you show the connect doce then the database select code then the query? No one can tell from what you have posted what is wrong. Something like the below would be of great value, and also please enclose your code with [ code } and [ /code ] (without the spaces) when you post.[code]$connect = mysql_connect('localhost','username','password') or die("Could not connect to server. MySQL said: ".mysql_error());$select = mysql_select_db('mydatabse',$connect) or die("Could not select database. MySQL said: ".mysql_error());$query = "SELECT * FROM mytable where something = 'something'";echo $query'"<br />";$result = mysql_query($query,$connect) or die("Your query failed because: ".mysql_error());[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-53302 Share on other sites More sharing options...
trq Posted July 5, 2006 Share Posted July 5, 2006 From this, I can tell you a few things....[code]SELECT User_Name, Password FROM Table_1 WHERE User_Name = ''[/code]Firstly. Password is a reserved word in mySql so it will needs to be surrounded in `backticks` (not they are NOT quotes). Secondly, Your $username variable is empty. I assume its comming from a form or somewhere but cant help without seeing your code. Quote Link to comment https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-53344 Share on other sites More sharing options...
PC Nerd Posted July 6, 2006 Author Share Posted July 6, 2006 ok, the site is completely database driven, so every page connects to the same db i simpply include to file, so ill post the entire inc filehere it goes$host="localhost";$account="USERNAME";$password="PASSWORD";$dbname="DBNAME";$Error_Log[1] = ""$Error_Log[2] = ""$DB_Server = mysql_connect($host, $account, $password);if(!$DB_Server){echo "<p>There was an error in connecting to the database server. Please try again later.</p>"; $Error_Log[1] = "DB_Server";}else{continue;}$DB = mysql_select_db($dbname);if(!$DB){echo "<p>There was an error connecting to the Database. Please try Again later.</p>"; $Error_Log[2] = "DB_Connect";}else{continue;}if(empty($Error_Log[1])){continue;}elseif(empty($Error_Log[2])){continue;}else{echo <p>We apologise for any and all inconveniences caused by this fualt in the system. We are working on fixing the connection problem. Why not explore the public site for FAQ's.</p>";} Quote Link to comment https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-53648 Share on other sites More sharing options...
trq Posted July 6, 2006 Share Posted July 6, 2006 Cool. Did you even read my previous post?PS: Just a tip here, but, seeing as you seem to be new to this, the code posted above is what I would regard as non-standard. Ok, there are no standards in php but following some simple guidelines will make it easier for you (in the future) and for us (right now) to debug your problems.Squeezing all your code onto one (or few) lines using syntax like...[code=php:0]if (true) {$b=1;echo $b+1;die();}[/code]Does not make programs run faster, not does it help AT ALL in the debuging process. Just because it can be done, doesn't meen it should.Sorry if this is offensive in any way, but really, if you want to code like that, go ahead, if you want help, posting code the rest of us can easily read. eg;[code=php:0]if (true) { $b = 1; echo $b+1; die();}[/code]Would be benoficial.Its only going to make your applications more robust, and more easily extendable.Some of the biggest frameworks around use simplified code for this very reason. Its easy to see whats going on. Quote Link to comment https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-53658 Share on other sites More sharing options...
PC Nerd Posted July 6, 2006 Author Share Posted July 6, 2006 actually i find it easier to debug loops that only have one statement when they are all of one line. i agree when there are more lines or statements then they shouldbe spread over many lines indented etc. and no i dont take any offence at the comment and do you have any suggections on how to fix the problem Quote Link to comment https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-53659 Share on other sites More sharing options...
trq Posted July 6, 2006 Share Posted July 6, 2006 [quote]do you have any suggections on how to fix the problem[/quote]Yes... I posted your problems (and some pointers to a solution) a couple of posts ago. Quote Link to comment https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-53675 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.