RubenDebusscher Posted March 3, 2016 Share Posted March 3, 2016 (edited) I am building a website about Doctor who, and I want to post various quotes from a database, when I wrote the select-query, I got the following error: Quotes Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /customers/e/a/c/doctorwhofans.be/httpd.www/test/Content/Quotes.php on line 106 (which is the one with the while expression). <?php //verbinding met de database require("./connect.php"); //select-query schrijven en uitvoeren $sql = " select * from QuotesTabel"; $result = mysql_query($sql); //alle records weergeven (terwijl er rijen gevonden worden. while ($row = mysql_fetch_assoc($result)) { //toon foto met info require("./ToonFoto.php"); } ?> Can someone help me please? Edited March 3, 2016 by RubenDebusscher Quote Link to comment https://forums.phpfreaks.com/topic/300922-error-received-quotes-warning-mysql_fetch_assoc-expects-parameter-1-to-be-resource-boolean-given-in-customerseacdoctorwhofansbehttpdw/ Share on other sites More sharing options...
Barand Posted March 3, 2016 Share Posted March 3, 2016 $result = mysql_query($sql); If the query fails, $result is "false". After call to mysql_query, check to see what "echo mysql_error();" outputs to find out why it failed. And read the message in red in my sig below. Quote Link to comment https://forums.phpfreaks.com/topic/300922-error-received-quotes-warning-mysql_fetch_assoc-expects-parameter-1-to-be-resource-boolean-given-in-customerseacdoctorwhofansbehttpdw/#findComment-1531667 Share on other sites More sharing options...
RubenDebusscher Posted March 3, 2016 Author Share Posted March 3, 2016 The reason I still use mysql_functions, is, because, that is how I learned it, last year. And when I tried to use mysqli for the last time, I had more errors than I have now, although, I am trying to use the statement you proposed. Quote Link to comment https://forums.phpfreaks.com/topic/300922-error-received-quotes-warning-mysql_fetch_assoc-expects-parameter-1-to-be-resource-boolean-given-in-customerseacdoctorwhofansbehttpdw/#findComment-1531668 Share on other sites More sharing options...
Jacques1 Posted March 3, 2016 Share Posted March 3, 2016 There are a couple of excellent PDO tutorials which explain everything you need to know: (The only proper) PDO tutorial PDO Tutorial for MySQL Developers Sticking to the mysql_* functions is not an option, because they've been removed entirely from the current PHP version. As soon as the server is updated, you'll have to write all the code again. Besides that, the old MySQL extension is infamous for security issues. Quote Link to comment https://forums.phpfreaks.com/topic/300922-error-received-quotes-warning-mysql_fetch_assoc-expects-parameter-1-to-be-resource-boolean-given-in-customerseacdoctorwhofansbehttpdw/#findComment-1531669 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.