Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
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.

Reply With Quote
  #2 (permalink)  
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.

Reply With Quote
  #3 (permalink)  
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

Reply With Quote
  #4 (permalink)  
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'

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 12:23 AM



All times are GMT -4. The time now is 10:47 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.