Jump to content

Archived

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

PC Nerd

mysqli_Query() error

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

Share this post


Link to post
Share on other sites
$result = mysql_query($User_SQL, $DB_Server);

change to this ok

Share this post


Link to post
Share on other sites
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.  :(

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
im using php 4.4.2
and mysql 4.1.19

iis 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

Share this post


Link to post
Share on other sites
As has already been said, use the mysql* functions, NOT mysqli*

Share this post


Link to post
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

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites
ive changed the line and have been given the following:

ERROR

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in URL on line 44
Unable to perform query: SELECT User_Name, Password FROM Table_1 WHERE User_Name = ''

Share this post


Link to post
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]

Share this post


Link to post
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.

Share this post


Link to post
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>";}

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
[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.

Share this post


Link to post
Share on other sites

×

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.