Padgoi Posted April 25, 2013 Share Posted April 25, 2013 $q = 'SELECT y.*, (SUM(`rating`)/COUNT(`rating`)) AS `avg`, COUNT(`rating`) AS `num_rat` FROM `groupcomic` `y` LEFT JOIN `yrat` ON `sid` = `skey` where panels>=3 GROUP BY `sid` ORDER BY `avg` DESC LIMIT 0,5'; This line seems to be causing problems in one of my scripts in that it keeps referring me to this line and saying there is an invalid MYSQL result resource. I'm fairly certain my table structure is off. Can someone please tell me, based on this line, what fields I should have in my table and and what type they should be? I know the table name is groupcomic. Link to comment https://forums.phpfreaks.com/topic/277309-table-structure-question/ Share on other sites More sharing options...
Padgoi Posted April 25, 2013 Author Share Posted April 25, 2013 Yeah, it's actually 2 tables, groupcomic and yrat. I ran the query directly in MYSQL and got this error: #1064 - 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 '$q = 'SELECT y.*, (SUM(`rating`)/COUNT(`rating`)) AS `avg`, COUNT(`rating`) AS `' at line 1 I assume it has something to do with the num_rat field but I honestly have no idea. I had that field set up as INT (11). Link to comment https://forums.phpfreaks.com/topic/277309-table-structure-question/#findComment-1426593 Share on other sites More sharing options...
mac_gyver Posted April 25, 2013 Share Posted April 25, 2013 you would only run the sql part of that statement directly in mysql. the leading $q = ' ... and ending '; are php code, not sql. Link to comment https://forums.phpfreaks.com/topic/277309-table-structure-question/#findComment-1426600 Share on other sites More sharing options...
Padgoi Posted April 25, 2013 Author Share Posted April 25, 2013 Ok, so I did that and got this error: #1064 - 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 ''' at line 1 Link to comment https://forums.phpfreaks.com/topic/277309-table-structure-question/#findComment-1426611 Share on other sites More sharing options...
mac_gyver Posted April 25, 2013 Share Posted April 25, 2013 about the only way you could get that error from that sql statement is if you left the leading or trailing php single quote ' on it when you copied/pasted it into mysql to run it. the sql you posted doesn't produce that error for me when i tried it directly in mysql. Link to comment https://forums.phpfreaks.com/topic/277309-table-structure-question/#findComment-1426631 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.