jesushax Posted March 27, 2008 Share Posted March 27, 2008 hi could somone tell me why this brings up a mysql error please the error is 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 'ORDERBY NewsDateAdded DESC' at line 1 cheers $max = 3; //amount of articles per page. change to what to want $p = @$_GET['p']; if(empty($p)) { $p = 1; } $limits = ($p - 1) * $max; //view all the news articles in rows $sql = mysql_query("SELECT * FROM tblNews LIMIT ".$limits.",".$max." ORDER BY NewsDateAdded DESC") or die(mysql_error()); //the total rows in the table $totalres = mysql_result(mysql_query("SELECT COUNT(NewsID) AS tot FROM tblNews"),0); //the total number of pages (calculated result), math stuff... $totalpages = ceil($totalres / $max); echo '<h3>News</h3>'; echo "<div style='text-align:center;'>View Page: "; for($i = 1; $i <= $totalpages; $i++){ //this is the pagination link echo "<a href='short_news.php?p=$i'>$i</a>|"; } echo "</div>"; $i = 0; Link to comment https://forums.phpfreaks.com/topic/98167-order-by-error/ Share on other sites More sharing options...
eddierosenthal Posted March 27, 2008 Share Posted March 27, 2008 looks like you have double quotes within double quotes. you might surround the inner doubles with outer single quotes? hth Link to comment https://forums.phpfreaks.com/topic/98167-order-by-error/#findComment-502244 Share on other sites More sharing options...
moon 111 Posted March 27, 2008 Share Posted March 27, 2008 LIMIT must be at the end of the query: $sql = mysql_query("SELECT * FROM tblNews ORDER BY NewsDateAdded DESC LIMIT ".$limits.",".$max) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/98167-order-by-error/#findComment-502245 Share on other sites More sharing options...
jesushax Posted March 27, 2008 Author Share Posted March 27, 2008 thanks moon Link to comment https://forums.phpfreaks.com/topic/98167-order-by-error/#findComment-502247 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.