Jump to content

Recommended Posts

hey guys
im 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 44

LINE 44 IS:  $result = mysqli_query($User_SQL, $DB_Server);

i am really stumped

i 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 appreciated

PC Nerd
Link to comment
https://forums.phpfreaks.com/topic/13633-mysqli_query-error/
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-52861
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-52898
Share on other sites

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 44

Warning: 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
Link to comment
https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-53280
Share on other sites

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?
Link to comment
https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-53282
Share on other sites

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]
Link to comment
https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-53302
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-53344
Share on other sites

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 file

here 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>";}
Link to comment
https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-53648
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-53658
Share on other sites

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
Link to comment
https://forums.phpfreaks.com/topic/13633-mysqli_query-error/#findComment-53659
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.