Forum Moderators: open

Message Too Old, No Replies

Syntax Error

         

dwighty

1:04 pm on May 11, 2006 (gmt 0)

10+ Year Member



Hi there, was wandering if anyone would be able to help with this error, am I doing something wrong?

$result = $db->sql_query('SELECT t.topicid, t.topicimage, t.topictext, count(s.sid) AS stories, SUM(s.counter) AS reads
FROM '.$prefix.'_topics t, '.$prefix.'_stories s WHERE s.topic = t.topicid
GROUP BY t.topicid, t.topicimage, t.topictext ORDER BY t.topictext',false, __FILE__, __LINE__);

/* and */

$result2 = $db->sql_query('SELECT s.sid, s.catid, s.title, c.title AS cat_title FROM '.$prefix.'_stories s, '.$prefix."_stories_cat c WHERE s.catid=c.catid
WHERE s.topic='$topicid' ORDER BY s.sid DESC LIMIT 0,10",false, __FILE__, __LINE__);

/* Error Msg */
CMS Warning line 51: On /index.php?name=Topics While executing query "SELECT t.topicid, t.topicimage, t.topictext, count(s.sid) AS stories, SUM(s.counter) AS reads FROM cms_topics t, cms_stories s WHERE s.topic = t.topicid GROUP BY t.topicid, t.topicimage, t.topictext ORDER BY t.topictext" the following error occured: 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 'reads FROM cms_topics t, cms_stories s WHERE s.topic = t.topici In: /******/modules/Topics/index.php on line: 22

Thanks for your time.

ChadSEO

2:00 pm on May 11, 2006 (gmt 0)

10+ Year Member



dwighty,

"reads" may be be a reserved keyword on your system. Try changing it to another word, or surround it by double-quotes.

Chad

dwighty

10:37 am on May 15, 2006 (gmt 0)

10+ Year Member



ChadSEO,

Thanks for your help, situation resolved.

Dwighty