co.ador Posted July 25, 2009 Share Posted July 25, 2009 Hi there is an error in line 110 Parse error: syntax error, unexpected ')' in /home4/ryanrees/public_html/crap/myrating.php.php on line 110 can any body help the script is below and line 110 is commented. <?php require_once("classes/include.all.php"); ?> <?php if(isset($_POST['submit' ])){ $nickname = mysql_real_escape_string($_POST['nickname']); $email = mysql_real_escape_string($_POST['email']); $comment = mysql_real_escape_string($_POST['comment']); $query = "INSERT INTO comment VALUES ( NOW(), '$nickname' , '$email', '$comment',)"; echo $query; $result = mysql_query($query) or die (mysql_error()); header("Location: http://localhost/ratingsystem/myrating.php"); exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Help on building a rating system for the commnury </title> <link type="text/css" href="../wamp/www/nyhungry/restaurants/styles/rating.css" rel="stylesheet" media="all" /> <script type="text/javascript" src="../scripts/prototype.js"></script> <script type="text/javascript" src="../scripts/rating.js"></script> </head> <body> <h4>Help on Building this Rating System for the use of the Community</h4> <h3>Demo Rating System:</h3> Nike Air Jordan:<?php $ratingData = Rating::OutputRating('demo'); if (Error::HasErrors()) { echo Error::ShowErrorMessages(); Error::ClearErrors(); } else { echo $ratingData; } ?> Fila scot:<?php $ratingData = Rating::OutputRating('paul'); if (Error::HasErrors()) { echo Error::ShowErrorMessages(); Error::ClearErrors(); } else { echo $ratingData; } ?> Adidas Shaq:<?php $ratingData = Rating::OutputRating('matt'); if (Error::HasErrors()) { echo Error::ShowErrorMessages(); Error::ClearErrors(); } else { echo $ratingData; } ?> Convers Felix:<?php $ratingData = Rating::OutputRating('felo'); if (Error::HasErrors()) { echo Error::ShowErrorMessages(); Error::ClearErrors(); } else { echo $ratingData; } ?> Timberland:<?php $ratingData = Rating::OutputRating('carmelo'); if (Error::HasErrors()) { echo Error::ShowErrorMessages(); Error::ClearErrors(); } else { echo $ratingData; } ?> <?php $rResult = mysql_query( sprintf( "SELECT * FROM comments ORDER BY created ASC", ) // line 110 ); if(mysql_num_rows($rResult) > 0) { while($aComment = mysql_fetch_assoc($rResult)) { printf( '<img src="../images/line..gif" alt="df" width="400" height="1" /> <br /> <div class="comment" style="margin-bottom: 2em;"> <div class="author"> <strong>Nickname:</strong> %s </div> <br /> <div class="body"> <strong>E-mail:</strong> %s </div> <br /> <div class="body"> <strong>Comment:</strong> %s </div> <br /> <div class="meta-info" style="font-size: 0.8em; position:relative; left:300px;"> <strong>Time:</strong> %s </div> </div> ', $aComment['nickname'], $aComment['email'], $aComment['comment'], $aComment['created'] ); } } else { echo 'No comments has been posted!'; } ?> <tr> <td> <table width="487" style="top:850px;" class="calamar"> <td width="479" style=" line-height:3;"><strong>Comments:</strong></td> <tr></tr><td style="font-family:\'Times New Roman\', Times, serif; font-size:14px;"> <form id="itemcomments" action="../wamp/www/ratingsytem/myrating.php" method="post"> <fieldset> <legend>Make a comment on this rating system</legend> <div> <label for="nickname">Nickname:</label> <input type="text" name="nickname" id="nickname" maxlength="85" /> </div> <div> <label for="email">E-mail:</label> <input name="email" type="text" id="email" value="" size="22"> </div> <div> <label for="comment">comment:</label> <textarea name="comment" id="comment" cols="35" rows="5"></textarea> </div> <input type="submit" name="submit" value="Add Comment"> <input type="reset" value="Reset Fields"> </fieldset> </form> </table> </td> </tr> =------------------------------------------------------------------------------------------------------------------------------ </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/167417-parse-error-guys-help/ Share on other sites More sharing options...
wildteen88 Posted July 25, 2009 Share Posted July 25, 2009 personally I see no need for sprintf here $rResult = mysql_query( sprintf( "SELECT * FROM comments ORDER BY created ASC", ) // line 110 ); Remove sprint $rResult = mysql_query("SELECT * FROM comments ORDER BY created ASC"); Quote Link to comment https://forums.phpfreaks.com/topic/167417-parse-error-guys-help/#findComment-882797 Share on other sites More sharing options...
.josh Posted July 25, 2009 Share Posted July 25, 2009 As far as the actual error, it's because you have a comma in there, which makes sprint expect another argument, which you are not providing. But seeing as how you aren't actually doing anything sprintf specific, you should remove it altogether, as WT posted. Quote Link to comment https://forums.phpfreaks.com/topic/167417-parse-error-guys-help/#findComment-882800 Share on other sites More sharing options...
co.ador Posted July 25, 2009 Author Share Posted July 25, 2009 now is this guys it is the insert part of the script <?php if(isset($_POST['submit' ])){ $nickname = mysql_real_escape_string($_POST['nickname']); $email = mysql_real_escape_string($_POST['email']); $comment = mysql_real_escape_string($_POST['comment']); $query = "INSERT INTO comment VALUES ( NOW(), '$nickname' , '$email', '$comment',)"; echo $query; $result = mysql_query($query) or die (mysql_error()); header("Location: http://localhost/shoes/stores/itemdetailsrating.php"); exit; } ?> \ INSERT INTO comment VALUES ( NOW(), 'jonathan' , 'joelios', 'poloeiru',)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 ')' at line 1 I made the fixes you gave me now it's show the above message. Quote Link to comment https://forums.phpfreaks.com/topic/167417-parse-error-guys-help/#findComment-882819 Share on other sites More sharing options...
.josh Posted July 25, 2009 Share Posted July 25, 2009 okay so once again you have a random extra comma in your code, so it is expecting another value. Quote Link to comment https://forums.phpfreaks.com/topic/167417-parse-error-guys-help/#findComment-882822 Share on other sites More sharing options...
lonewolf217 Posted July 25, 2009 Share Posted July 25, 2009 you still have a trailing comma in your sql syntax Quote Link to comment https://forums.phpfreaks.com/topic/167417-parse-error-guys-help/#findComment-882823 Share on other sites More sharing options...
co.ador Posted July 25, 2009 Author Share Posted July 25, 2009 guys I found the problem the auto counting for the id wasn't provided '', plus I was putting a comma at the end of the injection now it is working $query = "INSERT INTO comment VALUES ( '', NOW(), '$nickname' , '$email', '$comment',)"; do you see the comma after $comment? well it was supposed to be without the comma I guess it was looking for another variable, Sorry mysql I was giving you a headache Lol thank you guys... Quote Link to comment https://forums.phpfreaks.com/topic/167417-parse-error-guys-help/#findComment-882829 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.