LambPatch Posted January 18, 2017 Share Posted January 18, 2017 I'm not that great at coding but do manage to muddle my way through stuff if I can understand it. I've got a project going where i'd like to have something like the example in w3schools. The link is this one. http://www.w3schools.com/php/php_ajax_database.asp I have been trying to replicate this on my own server but its not working. what I'm seeing is error message.Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in D:\Hosting\8937614\html\vfd\famguy1.php on line 40 I'm seeing on the php file there is a line that goes like this: mysqli_select_db($con,"ajax"); I looked it up but the explanation is very vague, changing databases. Can someone explain what's happening here in why? thanks, Gail Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted January 18, 2017 Share Posted January 18, 2017 (edited) You're looking at the wrong line. The error is caused by the mysqli_fetch_array() call, and this typically happens when a query fails and you don't bother to check for that. So there are actually two problems. First, you need to start checking for errors or enable exceptions so that mysqli does this automatically: // make mysqli throw an exception whenever it encounters a problem $mysqli_driver = new mysqli_driver(); $mysqli_driver->report_mode = MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT; Secondly, you need to fix the query itself. When you enable exceptions, you'll see the MySQL error in the message. Apart from that, w3schools is a very bad resource and known to spread false information. Don't use it for learning. Edited January 18, 2017 by Jacques1 Quote Link to comment Share on other sites More sharing options...
LambPatch Posted January 19, 2017 Author Share Posted January 19, 2017 Thanks Jacques1. I appreciate the help. Finding good material to learn from has been a real issue. Lots of old mysql code and its hard to find things that have a simple goal in mind. Many try to throw in 'extras' that make it hard to pick out what you're trying to accomplish from the fluff. Any suggestions on good beginner books, websites or whatever?Anyway, thanks again. Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted January 19, 2017 Share Posted January 19, 2017 I'm not aware of a good resource that covers all PHP topics. However, there are specialized tutorials. For example, there's an excellent tutorial for the PDO interface; PDO is similar to mysqli but much more convenient and powerful. 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.