Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

Blog module: database error is thrown when visiting an author's page

edited October 2015 in News & Announcements

When visiting a blog user's page (/blog/authors/1) it throws:

A Database Error Occurred Error Number: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'author_id` = 1 AND `.`published` = 'yes' GROUP BY `fuel_blog_posts`.`id` ORDER' at line 8 SELECT fuel_blog_posts.*, fuel_blog_posts.*, fuel_blog_users.display_name, CONCAT(fuel_users.first_name, " ", fuel_users.last_name) as author_name, YEAR(fuel_blog_posts.publish_date) as year, DATE_FORMAT(fuel_blog_posts.publish_date, "%m") as month, DATE_FORMAT(fuel_blog_posts.publish_date, "%d") as day FROM (`fuel_blog_posts`) LEFT JOIN `fuel_categories` ON `fuel_categories`.`id` = `fuel_blog_posts`.`category_id` LEFT JOIN `fuel_relationships` ON `fuel_relationships`.`candidate_key` = `fuel_blog_posts`.`id` AND fuel_relationships.candidate_table = "fuel_blog_posts" AND fuel_relationships.foreign_table = "fuel_tags" LEFT JOIN `fuel_blog_users` ON `fuel_blog_users`.`fuel_user_id` = `fuel_blog_posts`.`author_id` LEFT JOIN `fuel_users` ON `fuel_users`.`id` = `fuel_blog_posts`.`author_id` LEFT JOIN `fuel_tags` ON `fuel_tags`.`id` = `fuel_relationships`.`foreign_key` WHERE `.`author_id` = 1 AND `.`published` = 'yes' GROUP BY `fuel_blog_posts`.`id` ORDER BY `publish_date` desc Filename: fuel\codeigniter\database\DB_driver.php Line Number: 331

I've traced it back to line 18 of the blog module's views/themes/default/author.php on line 18 where it calls

<?php $posts = $author->posts; ?>

and get_posts in the Blog_user_model. Currently all I have found out is that


in get_posts returns NULL so this is why there is missing prefixes to column names ( AND `.`published` = 'yes' [..] WHERE `.`author_id` [..] and so on ) but I cannot seem to find out why or what. What have I done? Could you share some thoughts? :p

If it helps, I can visit all the other pages fine (search, /blog/authors).



  • edited 9:40PM
    I don't have copy of the blog handy to test but it seems it's in the record part of the model?

    Try $this->_parent_model->_tables
  • edited 9:40PM
    I believe this is fixed in the develop branch of the blog:
    (requires some SQL updates in the install/updates folder)
  • edited October 2015
    I'm already on the develop branch actually, I've forked the module and running my own develop branch which is up to date (well, technically infront :p) of the upstream branch.

    $ git merge upstream/develop Already up-to-date.
    I ran fuel_blog_uninstall.sql, then fuel_blog_install.sql and then fuel_blog_permissions_install.sql in install/ after I switched branches from master to develop.
  • edited 9:40PM
    I'm also getting

    A PHP ERROR WAS ENCOUNTERED Severity: Notice Message: Undefined index: comments Filename: models/blog_posts_model.php Line Number: 470 A PHP ERROR WAS ENCOUNTERED Severity: Warning Message: Invalid argument supplied for foreach() Filename: models/blog_posts_model.php Line Number: 476

    when viewing a single post's comment section. Are these related or shall I file this as a separate issue? I'm really not sure what I'm doing here to create so many issues :o
  • edited 9:40PM
    Those both look to be bugs. I've posted fixes for them in the develop branch.
  • edited 9:40PM
    Okay thanks. Happy to be a guinea pig to test them out.

    (and thanks also for answering so many of my questions!)
  • edited 9:40PM
    Okay, can confirm those two fixes are working. Thanks!
Sign In or Register to comment.