Noskiw Posted October 6, 2009 Share Posted October 6, 2009 This is so frustrating >.< >.< <?php $connect = mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("guest") or die(mysql_error()); $per_page = 5; $start = $_GET['start']; $record_count = mysql_num_rows(mysql_query("SELECT * FROM guest")); $max_pages = $record_count / $per_page; if(!$start){ $start = 0; $get = mysql_query("SELECT * FROM guest ORDER BY id DESC LIMIT $start, $per_page"); while($row2 = mysql_fetch_assoc($get)){ $name2 = $row2['name']; $email2 = $row2['email']; $message2 = $row2['message']; $date2 = $row2['date']; $time2 = $row2['time']; } } function bbcode($string){ if($string){ $bbcode_array = array('[b]','[/b]', '[u]', '[/u]', '[i]', '[/i]', '[code]', ' ', ''); $bbcode_array_2 = array('<b>', '</b>', '<u>', '</u>', '<i>', '</i>', '<center><div style="width:90%;padding:3px;background-color:#000099;color:#FFFFFF;border:2px solid;">', '</div></center>', '<img src="', '">'); $new_string_2 = str_ireplace($bbcode_array, $bbcode_array_2, $string); return $new_string_2; } } echo "<h1>Guestbook</h1><hr />"; $queryget = mysql_query("SELECT * FROM guest ORDER BY id DESC LIMIT".$start."") or die(mysql_error()); $querygetrownum = mysql_num_rows($queryget); if($querygetrownum == 0){ echo "No posts have been made yet! Be the first!"; } while ($row = mysql_fetch_assoc($queryget)) { $id = $row['id']; $name = $row['name']; $email = $row['email']; $message = $row['message']; $date = $row['date']; $time = $row['time']; echo "<table><tr><td><b>Posted by: ".$name."(".$email.") on " . $date . " at " . $time . "</b></td></tr><tr><td>" . nl2br(bbcode(strip_tags($message))) ."</td></tr></table>"; } if($_POST['submit']){ $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $date = date("Y-m-d"); $time = date("H:i:s"); if($name && $email && $message){ $querypost = mysql_query("INSERT INTO guest VALUES('','".$name."','".$email."','".$message."','".$date."','".$time."')"); echo "Please wait... <meta http-equiv='refresh' content='2'>"; }else{ echo "Please fill out all fields!"; } } echo "<hr />"; echo " <form action='index.php' method='POST'> <table width='100%'> <tr> <td width='7%' valign='top'> Your Name: </td> <td valign='top'> <input type='text' name='name' maxlength='25' /> </td> </tr> <tr> <td valign='top'> Your Email: </td> <td> <input type='text' name='email' maxlength='25' /> </td> </tr> <tr> <td valign='top'> Your Message: </td> <td> <textarea cols='20' rows='2' name='message' maxlength='250'></textarea> <p><input type='submit' name='submit' value='Post' /> </td> </tr> </table> </form>"; ?> <style type="text/css"> body{font-family:Arial;font-size:14px;background-image: url('./images/bg.png');color:#FFFF00;}h1{font-family:Arial;}hr{color:#FFFF00;} </style>[/code] it comes up with 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 'LIMIT0' at line 1 Please Help... xD Quote Link to comment https://forums.phpfreaks.com/topic/176721-solved-guestbook-help-please/ Share on other sites More sharing options...
Mchl Posted October 6, 2009 Share Posted October 6, 2009 And did you check the manual for proper syntax? Quote Link to comment https://forums.phpfreaks.com/topic/176721-solved-guestbook-help-please/#findComment-931708 Share on other sites More sharing options...
Noskiw Posted October 6, 2009 Author Share Posted October 6, 2009 i've read the manual and it doesn't seem to help... Quote Link to comment https://forums.phpfreaks.com/topic/176721-solved-guestbook-help-please/#findComment-931746 Share on other sites More sharing options...
Noskiw Posted October 6, 2009 Author Share Posted October 6, 2009 please help me, it's really frustrating. Quote Link to comment https://forums.phpfreaks.com/topic/176721-solved-guestbook-help-please/#findComment-931756 Share on other sites More sharing options...
cags Posted October 6, 2009 Share Posted October 6, 2009 The LIMIT keyword (just like most other keywords) requires a space after it. Quote Link to comment https://forums.phpfreaks.com/topic/176721-solved-guestbook-help-please/#findComment-931762 Share on other sites More sharing options...
Noskiw Posted October 6, 2009 Author Share Posted October 6, 2009 that was a test and you all failed... I put an extra "LIMIT" in somewhere $queryget = mysql_query("SELECT * FROM guest ORDER BY id DESC LIMIT".$start."") or die(mysql_error()); i put it there on purpose to see if anyone could catch it out. Quote Link to comment https://forums.phpfreaks.com/topic/176721-solved-guestbook-help-please/#findComment-931791 Share on other sites More sharing options...
cags Posted October 6, 2009 Share Posted October 6, 2009 Quote that was a test and you all failed... I put an extra "LIMIT" in somewhere $queryget = mysql_query("SELECT * FROM guest ORDER BY id DESC LIMIT".$start."") or die(mysql_error()); i put it there on purpose to see if anyone could catch it out. Erm... the code on that line is invalid and will cause an SQL syntax error (which I already pointed out). If your trying to say the LIMIT part shouldn't be there at all, without a crystal ball how exactly are we supposed to know you didn't want to LIMIT that particular query? You put it there on purpose, sure you did Quote Link to comment https://forums.phpfreaks.com/topic/176721-solved-guestbook-help-please/#findComment-931811 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.