Jump to content

Warning: mysqli_query() expects parameter 1 to be mysqli, null given


deemurphy

Recommended Posts

I decided to upgrade my site which was doing fine, but now I am getting the following: Warning: mysqli_query() expects parameter 1 to be mysqli, null given

in all my PHP files and I do not understand this error.

 

Thank you for any solution to this.

LadyDee

Link to comment
Share on other sites

We can't help much without seeing relevant code. The problem is that when using mysqli_query() in procedural style the first parameter needs to be the mysqli link. To be more specific we'll need to see some code.

Link to comment
Share on other sites

Did you inadvertently remove the database connection script from showcalendar_withevent.php, or accidentally delete it altogether? Can you post the code within

 . . . 

tags?

 

Warning: mysqli_error() expects parameter 1 to be mysqli, null given in /home/a3151982/public_html/showcalendar_withevent.php on line 203

Link to comment
Share on other sites

Did you edit this to post it here, or did you edit it to use during development? I wouldn't expect to see the root user being the account used for DB access on a hosted site. Also, usually (but not always) the database server isn't at localhost.

 

$mysqli = mysqli_connect("localhost", "root", "ladydee", "ladydee");

Link to comment
Share on other sites

You should edit that file and remove your connection details immediately.

 

Your problem is that $mysqli is never set, you're also mixing mysql and mysqli functions, you can't do that.

Link to comment
Share on other sites

The mysql and mysqli extensions use a somewhat different syntax, but it looks like the script was written with the mysql extension originally, then an attempt was made to modify it. If that's the case, you should be able to change the mysqli's back to mysql. If that doesn't work, I'm sure someone here can help out.

Link to comment
Share on other sites

The second parameter in a mysql_query() function call is an optional mysql link resource. Your's is not one.

 

You would need to troubleshoot why the second parameter you are supplying is not a mysql link resource and make it the one that your mysql_connect() created.

Link to comment
Share on other sites

No one can really help you with what is specifically wrong with your code without seeing the code that produces the error. I told you what the error means, if you don't understand what the parameters are in a function call or where or if they are getting set to the correct values, you will need to post your code.

Link to comment
Share on other sites

That code isn't even using mysql_query() so it cannot be the code you were using that produced the error you posted in Reply #14. In fact, it is probably the original code you stared with and it produces the error message in the title of this thread.

 

When your problem is a moving target of randomly changing code and errors that don't even match the code you provide, no one really wants to try to chase down what you are changing in it.

 

You have had both the mysqli and mysql errors explained and been told that you cannot mix mysql and mysqli functions in one script. You must pick one way or the other and all the database related code on any page must use the same type.

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