-6

Direct to the Topic..

Here's the error:

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, string given in /home/u861005887/public_html/blog/rating/index.php on line 55

Here's the screenshot of the error:

http://i.imgur.com/69hOvSl.png

The content was rated # times is not working.
The rating is at # is not working.

How do I fix this?

RichardBernards
  • 3,158
  • 1
  • 21
  • 30
  • 4
    Debugging code without seeing the code is … hard. I bet you're passing the query to `mysql_fetch_assoc` instead of running the query and executing the result. You are using [an **obsolete** database API](http://stackoverflow.com/q/12859942/19068) and should use a [modern replacement](http://php.net/manual/en/mysqlinfo.api.choosing.php) anyway. – Quentin Dec 11 '14 at 12:52
  • @Clive — string, not boolean. – Quentin Dec 11 '14 at 12:53
  • Fair point @Quentin, This one'll do then: http://stackoverflow.com/questions/4901728/mysql-fetch-array-expects-parameter-1-to-be-resource-string-given – Clive Dec 11 '14 at 12:54
  • My guess is that you forgot the `$` in front of the name of the variable that stores the result set. – axiac Dec 11 '14 at 12:57

1 Answers1

0

The error: "expects parameter 1 to be resource, string given in" explains thaht you pass a string to the function. mysql_fetch_assoc must receive the result of a mysql_query request for example and mysql_result must succeed first.

Moreover, mysql_ is obsolete, you should use PDO, it is highly recommanded.

KyleK
  • 3,674
  • 16
  • 28