0

I'm not that good in PHP, and I have no idea why I do getting this error. I've tried to print out some stuff to get rid of the error. For example my SQL query or the contents of the returned array, but it didn't prinetd out somewhy.

Comments table:

enter image description here

Posts table: enter image description here

enter image description here

enter image description here

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /Applications/MAMP/htdocs/atiwebNew/resources/func/blog.php on line 106

aegyed
  • 1,279
  • 2
  • 17
  • 38
  • 6
    [**Please, don't use `mysql_*` functions in new code**](http://bit.ly/phpmsql). They are no longer maintained [and are officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). See the [**red box**](http://j.mp/Te9zIL)? Learn about [*prepared statements*](http://j.mp/T9hLWi) instead, and use [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) - [this article](http://j.mp/QEx8IB) will help you decide which. If you choose PDO, [here is a good tutorial](http://j.mp/PoWehJ). – Madara's Ghost Apr 23 '13 at 11:06
  • you query might have failed returning FALSE. `$result=mysql_query($query);` `if($result) { while($row=mysql_fetch_assoc($result)) {...} }` – Waygood Apr 23 '13 at 11:06
  • 1
    On closer examination, the error is in MySQL syntax. Your `WHERE` clause is asking for `comment_id` to be equal to `$post_id` but there is no column named `comment_id`. Change it to `WHERE comments.id = {$post_id}` – hjpotter92 Apr 23 '13 at 11:09
  • @MadaraUchiha you must be right, but i need to examine the basics of PHP for now. :) – aegyed Apr 23 '13 at 11:21
  • @Waygood Hmm you were right, my query returns false :S but what shall i do then? – aegyed Apr 23 '13 at 11:25
  • @hjpotter92 hmm idk, i changed it to, 'comments'.'id' Probably my SQL query is wrong, and that causes the error isn't it? I updated my main question with new images, any idea what could be wrong in my sql query? – aegyed Apr 23 '13 at 11:27
  • echo $query and paste into phpmyadmin. "other admin tools are available" – Waygood Apr 23 '13 at 11:28
  • @AttilaEgyed There still is a `comments_id` in JOIN sub-clause. – hjpotter92 Apr 23 '13 at 11:33

0 Answers0