Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
Password Reminder
Register
| FAQ | Members List | Calendar | 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 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 Search this Thread Display Modes
  #1 (permalink)  
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

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
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



All times are GMT -4. The time now is 12:49 PM.


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