Jump to content

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


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