Jump to content
RubenDebusscher

Error received: Quotes Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /customers/e/a/c/doctorwhofans.be/httpd.w

Recommended Posts

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 by RubenDebusscher

Share this post


Link to post
Share on other sites

$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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.