adam291086 Posted October 3, 2007 Share Posted October 3, 2007 I have just done a tutorial on pagination. As i am new to this i am not sure what this error means. I am using the include syntax to call on the pagination document to act upon my view an album page. Can anyone see whats wrong with this code? Error 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 'table LIMIT 0, 25' at line 1 <?php WRONG USERNAMES AND PASSWORDS ECT ECT $db_server ="db11sdfds25.oneandone.co.uk"; $db_user = "dbo21dsfdsf8351273"; $db_pass = "adawmasdfdsn291086"; $db_name = "db21835sdfds1273"; $con = mysql_connect("$db_server","$db_user","$db_pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } $limit = 25; $query_count = "SELECT count(*) FROM table"; $result_count = mysql_query($query_count); $totalrows = mysql_num_rows($result_count); if(empty($page)){ $page = 1; } $limitvalue = $page * $limit - ($limit); $query = "SELECT * FROM table 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>"); while($row = mysql_fetch_array($result)){ if ($bgcolor == "#E0E0E0"){ $bgcolor = "#FFFFFF"; }else{ $bgcolor = "#E0E0E0"; } echo("<tr bgcolor=".$bgcolor.">n<td>"); echo($row["users"]); echo("</td>n<td>"); echo($row["usersID"]); echo("</td>n</tr>"); } echo("</table>"); if($page != 1){ $pageprev = $page--; echo("<a href=\"$PHP_SELF&page=$pageprev\">PREV".$limit."</a> "); }else{ echo("PREV".$limit." "); } $numofpages = $totalrows / $limit; for($i = 1; $i <= $numofpages; $i++){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?page=$i\">$i</a> "); } } if(($totalrows % $limit) != 0){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?page=$i\">$i</a> "); } } if(($totalrows - ($limit * $page)) > 0){ $pagenext = $page++; echo("<a href=\"$PHP_SELF?page=$pagenext\">NEXT".$limit."</a>"); }else{ echo("NEXT".$limit); } mysql_free_result($result); ?> Quote Link to comment https://forums.phpfreaks.com/topic/71654-solved-pagination/ Share on other sites More sharing options...
MadTechie Posted October 3, 2007 Share Posted October 3, 2007 is the mySQL table called "Table" ? $query = "SELECT * FROM table LIMIT $limitvalue, $limit"; $query_count = "SELECT count(*) FROM table"; Quote Link to comment https://forums.phpfreaks.com/topic/71654-solved-pagination/#findComment-360727 Share on other sites More sharing options...
adam291086 Posted October 3, 2007 Author Share Posted October 3, 2007 sorry forgot to change that. Have changed it now and i still get the same problem. Quote Link to comment https://forums.phpfreaks.com/topic/71654-solved-pagination/#findComment-360730 Share on other sites More sharing options...
MadTechie Posted October 3, 2007 Share Posted October 3, 2007 the "table" probably doesn't exist, is it the exact same error Quote Link to comment https://forums.phpfreaks.com/topic/71654-solved-pagination/#findComment-360731 Share on other sites More sharing options...
haaglin Posted October 3, 2007 Share Posted October 3, 2007 add quotes: $query = "SELECT * FROM 'table' LIMIT $limitvalue, $limit"; Quote Link to comment https://forums.phpfreaks.com/topic/71654-solved-pagination/#findComment-360732 Share on other sites More sharing options...
adam291086 Posted October 3, 2007 Author Share Posted October 3, 2007 Right the code seems to process. All i get is a list on 'N' down the page and nothing happens to the number of pictures. I am using the syntax "include" to use this pagination code on the php code that gets everything from the database to display the pictures. You can see the results at http://adamplowman.co.uk/display_album.php?album_id=30. Quote Link to comment https://forums.phpfreaks.com/topic/71654-solved-pagination/#findComment-360737 Share on other sites More sharing options...
adam291086 Posted October 3, 2007 Author Share Posted October 3, 2007 Sorry im being an idiot.It's all sorted now. Cheers Quote Link to comment https://forums.phpfreaks.com/topic/71654-solved-pagination/#findComment-360738 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.