Jump to content

Warning: mysqli_query() expects parameter 1 to be mysqli


peterthiongo

Recommended Posts

MySQL queries work fine locally but when uploaded to server. I keep getting the following error from my database connection file. Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in Here is the line the error occurs

list($admin_domain_name) = mysqli_query($db, ("select domain_name from system where site_type = 'backend'"));

I have set $db as follows:

$db=@mysqli_select_db($connect, $database['database']) or die ("Couldn't select database");

Link to comment
Share on other sites

This is outdated information -- like many other parts of the FAQ.

 

As explained above, the modern and much more sane solution is to enable mysqli exceptions. There's absolutely no reason to go through the same manual error checks over and over again when mysqli can do that automatically.

 

Literally outputting the error message is also ill-advised, even during development.

Edited by Jacques1
Link to comment
Share on other sites

Yeah, the FAQ page should be updated. I only pointed to the entry because of the following:

 

mysql* expects parameter 1 to be resource, boolean given

This means your query failed, for some reason or another....

 

 

I hoped that seeing what the error meant would help clarify the suggestions you offered.

Link to comment
Share on other sites

OP has already asked and been answered on another forum.

 

*sigh*

 

Looks like some people spend more time cross-posting their question into every forum they can find than actually reading the replies and learning from them.

 

But as long as it costs nothing, let's keep everybody busy, eh?

Edited by Jacques1
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.