Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0
This is the forum to discuss the Wrox book Beginning PHP5, Apache, and MySQL Web Development by Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz, Michael K. Glass; ISBN: 9780764579660
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 10th, 2005, 11:41 AM
Registered User
 
Join Date: Jun 2005
Location: London, , United Kingdom.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Draconian
Default Trouble viewing the forum (ch. 16)

I'm having trouble with my viewforum.php code. When I try and access the page, I get this error message:

Quote:
quote:You have an error in your SQL syntax near '.id as topic_id, t.subject as t_subject, u.name as t_author, count(p.id) as numr' at line 1
SELECT SQL_CALC_FOUND_ROWS t.id as topic_id, t.subject as t_subject, u.name as t_author, count(p.id) as numreplies, t.date_posted as t_posted, tmp.postdate as re_posted FROM forum_users u JOIN forum_posts t ON t.author_id = u.id LEFT JOIN tmp ON t.id = tmp.topic_id LEFT JOIN forum_posts p ON p.topic_id = t.id WHERE t.forum_id = 1 AND t.topic_id = 0 GROUP BY t.id ORDER BY re_posted DESC, t_posted DESC, LIMIT 0, 10
This is the offending pice of code:

Code:
$sql = "SELECT SQL_CALC_FOUND_ROWS " .
           "t.id as topic_id, t.subject as t_subject, " .
           "u.name as t_author, count(p.id) as numreplies, " .
           "t.date_posted as t_posted, tmp.postdate as re_posted " .
         "FROM forum_users u " .
         "JOIN forum_posts t " .
         "ON t.author_id = u.id " .
         "LEFT JOIN tmp " .
         "ON t.id = tmp.topic_id " .
         "LEFT JOIN forum_posts p " .
         "ON p.topic_id = t.id " .
         "WHERE t.forum_id = $forumid " .
         "AND t.topic_id = 0 " .
         "GROUP BY t.id " .
         "ORDER BY re_posted DESC, t_posted DESC, " .
         "LIMIT $start, $limit";
  $result = mysql_query($sql)
    or die(mysql_error()."<br>".$sql);
    $numrows = mysql_num_rows($result);


I really can't see where I'm going wrong. Any help would be marvelous.

 
Old June 10th, 2005, 12:09 PM
Registered User
 
Join Date: Jun 2005
Location: London, , United Kingdom.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Draconian
Default

Also, it's running on MySQL 3.23.49 if that makes any difference.

 
Old June 16th, 2005, 03:47 PM
Authorized User
 
Join Date: Jun 2004
Location: , , .
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually, it does.
SQL_CALC_FOUND_ROWS was introduced in MySQL 4.0.0: http://dev.mysql.com/doc/mysql/en/in...functions.html

 
Old August 26th, 2005, 02:02 AM
Registered User
 
Join Date: Mar 2005
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

go to your functions.php file and change all: mod to: 'mod'





Similar Threads
Thread Thread Starter Forum Replies Last Post
Try it out:Ch 16 Dataset Example flhartley VB.NET 2002/2003 Basics 1 August 28th, 2009 07:00 AM
Chapter 16 forum - SQL error petefernando PHP Databases 3 October 22nd, 2007 07:13 PM
question about viewing/editing js file in ch 2 troutguy BOOK: Professional Ajax ISBN: 978-0-471-77778-6 1 August 25th, 2006 09:48 PM
Chapter 16 forum - SQL error petefernando Beginning PHP 2 March 31st, 2006 01:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.