kernelgpf Posted December 9, 2008 Share Posted December 9, 2008 The error: "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 '() LIMIT 1' at line 1" The code: mysql_query("SELECT pet_id from pets ORDER BY pet_id DESC() LIMIT 1")or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/136275-query-problem-with-limit/ Share on other sites More sharing options...
mkebkr04 Posted December 9, 2008 Share Posted December 9, 2008 $query = "SELECT pet_id from pets ORDER BY pet_id DESC() LIMIT 1")or die(mysql_error())"; $result = mysql_query($query); Link to comment https://forums.phpfreaks.com/topic/136275-query-problem-with-limit/#findComment-710909 Share on other sites More sharing options...
kernelgpf Posted December 9, 2008 Author Share Posted December 9, 2008 ... I omitted surrounding code to get to the base of the problem. Link to comment https://forums.phpfreaks.com/topic/136275-query-problem-with-limit/#findComment-710913 Share on other sites More sharing options...
mkebkr04 Posted December 9, 2008 Share Posted December 9, 2008 So you found your answer? Link to comment https://forums.phpfreaks.com/topic/136275-query-problem-with-limit/#findComment-710914 Share on other sites More sharing options...
kernelgpf Posted December 9, 2008 Author Share Posted December 9, 2008 No. I meant I know how to do basic MySQL and your answer is not the solution. My entire code is this: $IDquery=mysql_query("SELECT pet_id from pets ORDER BY pet_id DESC() LIMIT 1")or die(mysql_error()); $IDrow=mysql_fetch_array($IDquery); $babyID2=$IDrow[pet_id]; Link to comment https://forums.phpfreaks.com/topic/136275-query-problem-with-limit/#findComment-710915 Share on other sites More sharing options...
teng84 Posted December 9, 2008 Share Posted December 9, 2008 not sure if putting the " () " on your DESC clause is right DESC() should be "SELECT pet_id from pets ORDER BY pet_id DESC LIMIT 1" Link to comment https://forums.phpfreaks.com/topic/136275-query-problem-with-limit/#findComment-710932 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.