neex1233 Posted July 11, 2009 Share Posted July 11, 2009 Hi, I made a comment script. Here it is! <?php $allow = array ('5');include ("/home/username/public_html/folder/protect.php"); ?> <title>Post a Comment</title> <?php $con = mysql_connect("localhost","Username","Password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("DB_Name", $con); $username = mysql_real_escape_string($_SESSION["username"]); $sql = " SELECT * FROM `users` WHERE username = '$username' LIMIT 0, 30 "; $result = mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $userlevel = $row['userlevel']; } echo "$userlevel"; $poster = mysql_real_escape_string($_SESSION["username"]); $title = mysql_real_escape_string($_POST["title"]); $text = mysql_real_escape_string($_POST["text"]); $userlevel = $_SESSION['userlevel']; putenv("TZ=America/Los_Angeles"); $time = date("g:i A"); $date = date("M/j/Y"); if ( $userlevel == 5 ) { $table = comments; } else { if ( $userlevel == 4 or 3 or 2 ) { $table = ucomments; } else { echo "Sorry, you can't post comments because your userlevel is to low."; } function doSmily($msg) { $msg = str_ireplace('', '<img src="Smileys/happy.gif" alt="" />', $msg); $msg = str_ireplace('', '<img src="Smileys/sad.gif" alt="" />', $msg); $msg = str_ireplace('', '<img src="Smileys/biggrin.gif" alt="" />', $msg); $msg = str_ireplace('', '<img src="Smileys/wink.gif" alt="" />', $msg); $msg = str_ireplace('', '<img src="Smileys/ohmy.gif" alt="" />', $msg); $msg = str_ireplace(':X', '<img src="Smileys/angry.gif" alt=":X" />', $msg); $msg = str_ireplace('censored', '***', $msg); $msg = str_ireplace('censored', '****', $msg); $msg = str_ireplace('censored', '*****', $msg); $msg = str_ireplace('censored', '*****', $msg); $msg = str_ireplace('censored', '****', $msg); $msg = str_ireplace('censored', '*************', $msg); $msg = str_ireplace('censored', '******', $msg); $msg = str_ireplace('censored', '***', $msg); $msg = str_ireplace('censored', '***', $msg); $msg = str_ireplace('censored', '******', $msg); $msg = str_ireplace('censored', '******', $msg); $msg = str_ireplace('censored', '***', $msg); $msg = str_ireplace('censored', '****', $msg); $msg = str_ireplace('censored', '*****', $msg); $msg = str_ireplace('censored', '********', $msg); $msg = str_ireplace('censored', '*********', $msg); $msg = str_ireplace('censored', '*********', $msg); $msg = str_ireplace('censored', '********', $msg); $msg = str_ireplace('censored', '******', $msg); $msg = str_ireplace('censored', '******', $msg); $msg = str_ireplace('censored', '*******', $msg); $msg = str_ireplace('censored', '********', $msg); $msg = str_ireplace('censored', '*******', $msg); return $msg; } $input = "$text"; $input1 = "$title"; $ntext = doSmily($input); $ntitle = doSmily($input1); $stext = mysql_real_escape_string($ntext); $stitle = mysql_real_escape_string($ntitle); $sql="INSERT INTO $table (title,poster,text,time,date) VALUES ('$stitle','$poster','$stext','$time','$date')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "<strong>Comment Added!</strong>"; mysql_close($con) ?> But I always get this error: Parse error: syntax error, unexpected $end in /home/username/public_html/folder/news/post_comment.php on line 97 Could you tell me what's wrong? Also, do you think this script will work once I get this error fixed? Thanks! Link to comment https://forums.phpfreaks.com/topic/165563-php-comment-form/ Share on other sites More sharing options...
seventheyejosh Posted July 11, 2009 Share Posted July 11, 2009 2nd to last line needs a semi colon Link to comment https://forums.phpfreaks.com/topic/165563-php-comment-form/#findComment-873276 Share on other sites More sharing options...
neex1233 Posted July 11, 2009 Author Share Posted July 11, 2009 I still get the error. Link to comment https://forums.phpfreaks.com/topic/165563-php-comment-form/#findComment-873277 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.