Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
| Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases 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 March 7th, 2006, 02:02 PM
Registered User
 
Join Date: Mar 2006
Location: Birmingham, , United Kingdom.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 16 forum - SQL error

 Hi

I've got a copy of Beginning PHP5, Apache, and MySQL Web Development.

I've been working through Chapter 16 and get this error when loading the index page:

--------begin cut---------
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 'mod FROM forum_forum f LEFT JOIN forum_posts p ON f.id = p.forum_id AND ' at line 3
-------end cut--------

Here is the offending bit of code:


-------Begin cut--------
$sql = <<<EOS
  SELECT f.id as id, f.forum_name as forum,
    f.forum_desc as description,
    count(forum_id) as threads, u.name as mod
  FROM forum_forum f
  LEFT JOIN forum_posts p
  ON f.id = p.forum_id
  AND p.topic_id=0
  LEFT JOIN forum_users u
  ON f.forum_moderator = u.id
  GROUP BY f.id,
EOS;
--------end cut----------

Somone on another forum suggested I added "f.forum_name, f.forum_desc, u.name" on the end of the group by statement. I've tried this and it doesn't work.

Can anyone help????

Cheers
Pete Fernando

 
Old April 20th, 2006, 01:55 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Try asking in the book's forum located here,
http://p2p.wrox.com/forum.asp?FORUM_ID=157

Regards,
Rich

--
Author,
Beginning CSS: Cascading Style Sheets For Web Design
CSS Instant Results

http://www.catb.org/~esr/faqs/smart-questions.html
 
Old July 4th, 2007, 04:36 AM
Registered User
 
Join Date: Jul 2007
Location: kl, mal, Malaysia.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ambo
Default

me also got the same problem.

The error is something like this

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 'mod FROM forum_forum f LEFT JOIN forum_posts p ON f.id = p.forum_id AND ' at line 3

can anyone outthere help us

Thank u


aaaa
 
Old October 22nd, 2007, 07:13 PM
Registered User
 
Join Date: Oct 2007
Location: Brampton, ON, Canada.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

HI,

Please make a correction on the 3rd line of your sql string in the index.php. we should not use the special word "mod" . you should change this to something else such as "jod" or some other meaningful word. Following is the corrected sql string which I used.

------
$sql = <<<EOS
  SELECT f.id as id, f.forum_name as forum,
    f.forum_desc as description,
    count(forum_id) as threads, u.name as jod
  FROM forum_forum f
  LEFT JOIN forum_posts p
  ON f.id = p.forum_id
  AND p.topic_id=0
  LEFT JOIN forum_users u
  ON f.forum_moderator = u.id
  GROUP BY f.id
EOS;

--------

Hope this will help to everyone who get this same error..

Linus

Quote:
quote:Originally posted by ambo
 me also got the same problem.

The error is something like this

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 'mod FROM forum_forum f LEFT JOIN forum_posts p ON f.id = p.forum_id AND ' at line 3

can anyone outthere help us

Thank u


aaaa




Similar Threads
Thread Thread Starter Forum Replies Last Post
Forum Chapter 16 - changing the dates mr_badger BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 July 31st, 2008 07:50 PM
Search Error Chapter 16 EgoGen BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 June 12th, 2008 03:36 PM
Chapter 16 Sql connection error flashmanTom BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 1 May 22nd, 2008 05:04 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.