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.

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?

Link to comment
Share on other sites

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.