jimmyp3016 Posted December 12, 2006 Share Posted December 12, 2006 Hey All,When I analyze this code in Zend Studio it tells me nothing is wrong. But when my script posts on the web I get this error: "Query failed to execute correctly: 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 'SELECT DISTINCT u.referral FROM user u, transaction t WHERE u.i"My host uses PHP4. Is there anything in this syntax that would be in PHP5 only? Any help would be great.[code] $sql = "SELECT *, COUNT(id) AS referrals FROM user WHERE id IN ("; $sql .= "SELECT DISTINCT u.referral FROM user u, transaction t WHERE u.id = t.userID"; $sql .= ") GROUP BY id";[/code] Link to comment https://forums.phpfreaks.com/topic/30409-help-with-correct-syntaxplease/ Share on other sites More sharing options...
hitman6003 Posted December 12, 2006 Share Posted December 12, 2006 Are you sure that your version of MySQL supports nested queries? I think the MySQL version must be greater than 4.11, although you will have to check MySQL's documentation to be sure.The error is not in your php...it's in your SQL. Link to comment https://forums.phpfreaks.com/topic/30409-help-with-correct-syntaxplease/#findComment-139949 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.