peterthiongo Posted July 7, 2017 Share Posted July 7, 2017 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 occurslist($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"); Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted July 7, 2017 Share Posted July 7, 2017 Stop suppressing errors and printing internal messages on your website. Instead, enable mysqli exceptions, turn your error reporting all the way up and log the messages. On a live server, display_errors must always be off. Actually, you should keep the code in your local test environment until you understand the PHP basics. Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted July 7, 2017 Share Posted July 7, 2017 Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given This is a fairly common question that is addressed here: https://forums.phpfreaks.com/topic/273121-readme-php-resources-faqs/?do=findComment&comment=1428660 Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted July 7, 2017 Share Posted July 7, 2017 (edited) 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 July 7, 2017 by Jacques1 Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted July 7, 2017 Share Posted July 7, 2017 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. Quote Link to comment Share on other sites More sharing options...
benanamen Posted July 7, 2017 Share Posted July 7, 2017 OP has already asked and been answered on another forum. Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted July 7, 2017 Share Posted July 7, 2017 (edited) 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 July 7, 2017 by Jacques1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.