Jump to content

Help needed with a mysqli_error() expecting a parameter :)


Solarpitch

Recommended Posts

Hey Guys,

Here's my code..

[code]
$sql = "SELECT COUNT(*) as Num FROM adds2 WHERE class = 'Drivers' AND 'validation' = 1)";
  $res = mysqli_query($mysql_connect, $sql) or die (mysqli_error());
    $r=mysqli_fetch_assoc($res);
$tot = $r['Num'];
[/code]

and here's my error..

[code]
Warning: mysqli_error() expects exactly 1 parameter, 0 given in c:\webs\golftrader\retrieve_database.php on line 86
[/code]

I'd love some help to try and spot the problem, cant figure it out and its something simple . . I know it!
mysqli_error requirest the link identifier

The identifier is the variable that holds the connection when you connected to mysql.

I am guessing $mysql_connect is the variable that holds the identifier. SO use this instread:

[code=php:0]$res = mysqli_query($mysql_connect, $sql) or die (mysqli_error($mysql_connect));[/code]
not knowing a lot about mysqli I had a look around and the error sounds to me that it does not recognise anything you have put into the mysqli_query() function.

looking at your code:-
in line one - you have a closing brace at the end without a corresponding opening one - that could explain why it does not recognise that line
in line two -  you pass $mysql_connect to the function, does this exist as the connection statement in your code??
such as
[code]
<?php
$connection = mysql_connect('localhost', 'paul', 'password');
?>
[/code]
then pass it to your function such as
[code]
<?php
$res = mysqli_query($connection, $sql) or die (mysqli_error());
?>
[/code]
Paul

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.