HoTDaWg Posted July 16, 2006 Share Posted July 16, 2006 hey,I have the following script:[code]<?php$conn = mysql_connect("localhost","*****","******");mysql_select_db("*********"); $limit = 3; $query_count = "SELECT count(*) FROM news"; $result_count = mysql_query($query_count); $totalrows = mysql_num_rows($result_count); if(empty($page)){ $page = 1; } $limitvalue = $page * $limit - ($limit); $query = "SELECT * FROM news ORDER BY date DESC, LIMIT $limitvalue, $limit "; $result = mysql_query($query) or die("Error: " . mysql_error()); if(mysql_num_rows($result) == 0){ echo("Nothing to Display!"); } $bgcolor = "#E0E0E0"; // light gray echo("<table width=\"100%\" border=\"0\" height=\"0\" cellpadding=\"0\" cellspacing=\"0\">"); while($row = mysql_fetch_array($result)){ if ($bgcolor == "#E0E0E0"){ $bgcolor = "#CCCCCC"; }else{ $bgcolor = "#E0E0E0"; } echo("<tr bgcolor=".$bgcolor."><td width=\"10\">"); echo($row["id"]); echo("</td><td width=\"60%\"><li>"); echo($row["content"]); echo("</td><td width=\"30%\">"); echo($row["today"]); echo("</td></tr>"); } echo("</table>"); ?>[/code]Now i get the following error:[code]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 0, 3' at line 1[/code]Any help would greatly be appreciated,HoTDaWg Quote Link to comment https://forums.phpfreaks.com/topic/14734-pretty-noobish-error/ Share on other sites More sharing options...
leeming Posted July 16, 2006 Share Posted July 16, 2006 Dont have the comma ( , ) after DESC?soo..[code]$query = "SELECT * FROM news ORDER BY date DESC LIMIT $limitvalue, $limit "; [/code] Quote Link to comment https://forums.phpfreaks.com/topic/14734-pretty-noobish-error/#findComment-58790 Share on other sites More sharing options...
kenrbnsn Posted July 16, 2006 Share Posted July 16, 2006 Remove the comma between the words "DESC" snd "LIMIT"Ken Quote Link to comment https://forums.phpfreaks.com/topic/14734-pretty-noobish-error/#findComment-58792 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.