Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Bug Fixes
Author Message
gotcha
Regular
Regular


Joined: Mar 14, 2005
Posts: 91

PostPosted: Wed Feb 14, 2007 8:20 pm Reply with quote

So after switching servers I go to my topics module and all i see is this poorly written message
Quote:
...There aren't any news yet for this topic...


But really there "are news". So what it boiled down to is changing the query to work in this newer version of MySQL. Apparently "reads" is a reserved word now??

Old, Broken Version:
Code:
$sql = "SELECT t.topicid, t.topicimage, t.topictext, count(s.sid) AS stories, SUM(s.counter) AS reads FROM ".$prefix."_topics t LEFT JOIN ".$prefix."_stories s ON (s.topic = t.topicid) GROUP BY t.topicid, t.topicimage, t.topictext ORDER BY t.topictext";



I found by simply changing "reads" to something else fixed the problem.

Changed the above to:
Code:
$sql = "SELECT t.topicid, t.topicimage, t.topictext, count(s.sid) AS stories, SUM(s.counter) AS views FROM ".$prefix."_topics t LEFT JOIN ".$prefix."_stories s ON (s.topic = t.topicid) GROUP BY t.topicid, t.topicimage, t.topictext ORDER BY t.topictext";


Changed:
Code:
$output .= "<big><strong>&middot;</strong></big> <b>"._TOTREADS.":</b> ".(isset($row['reads']) ? $row['reads'] : 0)."</font>";


To:
Code:
$output .= "<big><strong>&middot;</strong></big> <b>"._TOTREADS.":</b> ".(isset($row['views']) ? $row['views'] : 0)."</font>";


And the topics module was back to normal.
 
View user's profile Send private message Visit poster's website
montego
Site Admin


Joined: Aug 29, 2004
Posts: 9456
Location: Arizona

PostPosted: Wed Feb 14, 2007 8:38 pm Reply with quote

gotcha, thanks for this. Just so the RavenNuke crowd knows, this is NOT an issue with that release because RavenNuke uses an enhanced Topics module. It does not have that issue.

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
Gremmie
Former Moderator in Good Standing


Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA

PostPosted: Sun Sep 02, 2007 10:17 am Reply with quote

I know this is old but in case anyone searches for this problem...

I think a simpler fix would be to put back ticks around reads in the SQL. I think that will tell MySQL not to confuse it with the new reserved word called READS.

For example:

Code:


$sql = "SELECT t.topicid, t.topicimage, t.topictext, count(s.sid) AS stories, SUM(s.counter) AS `reads` FROM ".$prefix."_topics t LEFT JOIN ".$prefix."_stories s ON (s.topic = t.topicid) GROUP BY t.topicid, t.topicimage, t.topictext ORDER BY t.topictext";

_________________
Only registered users can see links on this board! Get registered or login! - An Event Calendar for PHP-Nuke
Only registered users can see links on this board! Get registered or login! - A Google Maps Nuke Module 
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Bug Fixes

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©