dean7 Posted September 13, 2009 Share Posted September 13, 2009 Hi all ive trying to code a comment like thing for my website where users can comment on other users profiles: <?php ///////////// Start Of New Code /////////////// ///////////// Add Comment On Profile ////////// include ("config.php"); include ("makelogin.php"); ////////////// Includes ////////////////// $username = $logged['username']; $ul = $logged['userlevel']; $msg=strip_tags($_POST['msg']); $date = gmdate('Y-m-d h:i:s'); ///////////// Starting Varibals ////////////////// $query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1"); $fetch=mysql_fetch_object($query); ///////////// Querys ///////////////////////// if($ul == "owner"){ if (strip_tags($_POST['submit']) ///////////////////// Line 158 is The One BELOW This ////////////////////////////////// mysql_query("INSERT INTO `pmessages` ( `id` , `title` , `from` , `message` , `date` , `unread` ) VALUES ( '', 'Profile Comment', '$username', '$msg', '$date', 'unread' )"); echo ("<font color='black'>Comment Sent To $username!"); } ///////////// Sending The Comment They Sent /////////////////// ?> <html> <form method="post" action=""> <table width='80%' cellspacing='0' cellpadding='0' border='1' bordercolor='#000000'> <tr> <td> <p align="center">Comment To Send: <br> </td> </tr> <tr> <td> <textarea name="msg" cols="40" rows="8" id="msg"></textarea> </td> </tr> <tr> </td> <input type="submit" value="Send Comment"> </td> </tr> </table> </form> </html> I have an error saying : Parse error: syntax error, unexpected T_STRING in /home/a7502957/public_html/members.php on line 158 Any one know why? Thanks Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/ Share on other sites More sharing options...
ToonMariner Posted September 13, 2009 Share Posted September 13, 2009 perhaps if you hi-lighted the relevant portion of code it would help us identify the issue? Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917524 Share on other sites More sharing options...
dean7 Posted September 13, 2009 Author Share Posted September 13, 2009 perhaps if you hi-lighted the relevant portion of code it would help us identify the issue? What you mean? Thats all the code to the comment system. Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917526 Share on other sites More sharing options...
ToonMariner Posted September 13, 2009 Share Posted September 13, 2009 Parse error: syntax error, unexpected T_STRING in /home/a7502957/public_html/members.php on line 158 It would be great if you could highlight the line of code the parser is telling you to check. It may well be the actual issue is before this line so if you could show the code in members.php (as much as possible) so that we can see line 158 and what code relates to it. Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917528 Share on other sites More sharing options...
ngreenwood6 Posted September 13, 2009 Share Posted September 13, 2009 try this: <?php ///////////// Start Of New Code /////////////// ///////////// Add Comment On Profile ////////// include ("config.php"); include ("makelogin.php"); ////////////// Includes ////////////////// $username = $logged['username']; $ul = $logged['userlevel']; $msg=strip_tags($_POST['msg']); $date = gmdate('Y-m-d h:i:s'); ///////////// Starting Varibals ////////////////// $query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1"); $fetch=mysql_fetch_object($query); ///////////// Querys ///////////////////////// if($ul == "owner"){ if (strip_tags($_POST['submit'])) ///////////////////// Line 158 is The One BELOW This ////////////////////////////////// mysql_query("INSERT INTO pmessages ('id','title','from','message','date','unread') VALUES ( '', 'Profile Comment', '$username', '$msg', '$date', 'unread' )"); echo "<font color='black'>Comment Sent To $username!"; } ///////////// Sending The Comment They Sent /////////////////// ?> <html> <form method="post" action=""> <table width='80%' cellspacing='0' cellpadding='0' border='1' bordercolor='#000000'> <tr> <td> <p align="center">Comment To Send: <br> </td> </tr> <tr> <td> <textarea name="msg" cols="40" rows="8" id="msg"></textarea> </td> </tr> <tr> </td> <input type="submit" value="Send Comment"> </td> </tr> </table> </form> </html> Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917530 Share on other sites More sharing options...
PugJr Posted September 13, 2009 Share Posted September 13, 2009 if($ul == "owner"){ if (strip_tags($_POST['submit']) ///////////////////// Line 158 is The One BELOW This ////////////////////////////////// mysql_query("INSERT INTO `pmessages` ( `id` , `title` , `from` , `message` , `date` , `unread` ) VALUES ( '', 'Profile Comment', '$username', '$msg', '$date', 'unread' )"); echo ("<font color='black'>Comment Sent To $username!"); } Either I learned something or I see one thing you are doing wrong. At "if (strip_tags($_POST['submit'])" there is no "{". Now I could be wrong, but whats the point of an "if" if there is no "{"? Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917532 Share on other sites More sharing options...
dean7 Posted September 13, 2009 Author Share Posted September 13, 2009 Parse error: syntax error, unexpected T_STRING in /home/a7502957/public_html/members.php on line 158 It would be great if you could highlight the line of code the parser is telling you to check. It may well be the actual issue is before this line so if you could show the code in members.php (as much as possible) so that we can see line 158 and what code relates to it. I could show you all of my members.php file if you want? But that code there is basicly the comment system. Before i added that there it all work good.. But here is members.php with the other code in it.: <?php include('css/style.css'); include("makelogin.php"); include("functions.php"); ?> <? session_start(); ob_start(); include("config.php"); if (!$_GET[user]) { $getuser = mysql_query("SELECT * from users order by id asc"); while ($user = mysql_fetch_array($getuser)) { // gets all the users information. echo ("<a href=\"members.php?user=$user[username]\">$user[username]</a><br />\n"); // links to a page to view the user's profile. } } ELSE { $getuser = mysql_query("SELECT * from users where username = '$_GET[user]'"); $usernum = mysql_num_rows($getuser); if ($usernum == 0) { echo ("User Not Found"); } else { $profile = mysql_fetch_array($getuser); echo ("<center><table width='70%' border='1px' bordercolor='#000000' bgcolor='#666666'> <tr> <td background='tableheader.png'> <center><font color='black'>$profile[username] Profile</font></center> </td> </tr> </table> <table width='70%' border='1px' bordercolor='#000000' bgcolor='#666666'> <tr> <td> Username: </td> <td> <a href=\"messages.php?page=write\">$profile[username]</a> </td> <td> Email: </td> <td> $profile[email] </td> </tr> <tr> <td> Msn: </td> <td> $profile[msn] </td> <td> Aim: </td> <td> $profile[aim] </td> </tr> <tr> <td> Reg Date: </td> <td> 0000,00,00 </td> <td> Last Login: </td> <td> 0000,00,00 </td> </tr> <tr> <td> Location: </td> <td> $profile[location] </td> <td> Id: </td> <td> $profile[id] </td> </tr> <tr> <td> Level: </td> <td> $profile[level] </td> <td> Game Crew: </td> <td> $profile[gamecrew] </td> </tr> <tr> <td> Game Comment: </td> <td> $profile[comment] </td> </tr> </table> <table width='70%' border='1px' bordercolor='#000000' bgcolor='#666666'> <tr> <td background='tableheader.png'> <center><font color='black'>Content</font></center> </td> </tr> <tr> <td> $profile[content] </td> </tr> </table></center>"); // in the above code, we display the user's information. } } ?> <?php ///////////// Start Of New Code /////////////// ///////////// Add Comment On Profile ////////// include ("config.php"); include ("makelogin.php"); ////////////// Includes ////////////////// $username = $logged['username']; $ul = $logged['userlevel']; $msg=strip_tags($_POST['msg']); $date = gmdate('Y-m-d h:i:s'); ///////////// Starting Varibals ////////////////// $query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1"); $fetch=mysql_fetch_object($query); ///////////// Querys ///////////////////////// if($ul == "owner"){ if (strip_tags($_POST['submit']) mysql_query("INSERT INTO `pmessages` ( `id` , `title` , `from` , `message` , `date` , `unread` ) VALUES ( '', 'Profile Comment', '$username', '$msg', '$date', 'unread' )"); echo ("<font color='black'>Comment Sent To $username!"); } ///////////// Sending The Comment They Sent /////////////////// ?> <html> <form method="post" action=""> <table width='80%' cellspacing='0' cellpadding='0' border='1' bordercolor='#000000'> <tr> <td> <p align="center">Comment To Send: <br> </td> </tr> <tr> <td> <textarea name="msg" cols="40" rows="8" id="msg"></textarea> </td> </tr> <tr> </td> <input type="submit" value="Send Comment"> </td> </tr> </table> </form> </html> Sorry about length Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917533 Share on other sites More sharing options...
dean7 Posted September 13, 2009 Author Share Posted September 13, 2009 try this: <?php ///////////// Start Of New Code /////////////// ///////////// Add Comment On Profile ////////// include ("config.php"); include ("makelogin.php"); ////////////// Includes ////////////////// $username = $logged['username']; $ul = $logged['userlevel']; $msg=strip_tags($_POST['msg']); $date = gmdate('Y-m-d h:i:s'); ///////////// Starting Varibals ////////////////// $query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1"); $fetch=mysql_fetch_object($query); ///////////// Querys ///////////////////////// if($ul == "owner"){ if (strip_tags($_POST['submit'])) ///////////////////// Line 158 is The One BELOW This ////////////////////////////////// mysql_query("INSERT INTO pmessages ('id','title','from','message','date','unread') VALUES ( '', 'Profile Comment', '$username', '$msg', '$date', 'unread' )"); echo "<font color='black'>Comment Sent To $username!"; } ///////////// Sending The Comment They Sent /////////////////// ?> <html> <form method="post" action=""> <table width='80%' cellspacing='0' cellpadding='0' border='1' bordercolor='#000000'> <tr> <td> <p align="center">Comment To Send: <br> </td> </tr> <tr> <td> <textarea name="msg" cols="40" rows="8" id="msg"></textarea> </td> </tr> <tr> </td> <input type="submit" value="Send Comment"> </td> </tr> </table> </form> </html> That worked, Just now it isnt incerting into the database. Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917535 Share on other sites More sharing options...
ngreenwood6 Posted September 13, 2009 Share Posted September 13, 2009 i dont see a database connection. is that in the config.php file or the makelogin.php file? Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917537 Share on other sites More sharing options...
ToonMariner Posted September 13, 2009 Share Posted September 13, 2009 all apologies - I didn't see the comment in the line code... - my bad. ngreenwood picked up the missing brace on the if... Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917538 Share on other sites More sharing options...
dean7 Posted September 13, 2009 Author Share Posted September 13, 2009 i dont see a database connection. is that in the config.php file or the makelogin.php file? The connection is in the config file Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917539 Share on other sites More sharing options...
PugJr Posted September 13, 2009 Share Posted September 13, 2009 all apologies - I didn't see the comment in the line code... - my bad. ngreenwood picked up the missing brace on the if... I wasn't talking about the ")" which is one thing, but I just meant the "{" and "}" on the if. What does the "if" even do if there is no "{" and "}"? EDIT: Err nevermind. Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917541 Share on other sites More sharing options...
dean7 Posted September 13, 2009 Author Share Posted September 13, 2009 all apologies - I didn't see the comment in the line code... - my bad. ngreenwood picked up the missing brace on the if... I wasn't talking about the ")" which is one thing, but I just meant the "{" and "}" on the if. What does the "if" even do if there is no "{" and "}"? Ive added the "{" and "}" in but i dont think i did any difference. Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917542 Share on other sites More sharing options...
ngreenwood6 Posted September 13, 2009 Share Posted September 13, 2009 can you show me the code from the config.php file? Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917545 Share on other sites More sharing options...
dean7 Posted September 13, 2009 Author Share Posted September 13, 2009 can you show me the code from the config.php file? its the basic config file.. all it does is connect to the database.. Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917547 Share on other sites More sharing options...
ngreenwood6 Posted September 13, 2009 Share Posted September 13, 2009 try this then: <?php ///////////// Start Of New Code /////////////// ///////////// Add Comment On Profile ////////// include ("config.php"); include ("makelogin.php"); ////////////// Includes ////////////////// $username = $logged['username']; $ul = $logged['userlevel']; $msg=strip_tags($_POST['msg']); $date = gmdate('Y-m-d h:i:s'); ///////////// Starting Varibals ////////////////// $query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1"); $fetch=mysql_fetch_object($query); ///////////// Querys ///////////////////////// if($ul == "owner"){ if ($_POST['submit']) { ///////////////////// Line 158 is The One BELOW This ////////////////////////////////// mysql_query("INSERT INTO pmessages ('id','title','from','message','date','unread') VALUES ('','Profile Comment','$username','$msg','$date','unread')"); echo "<font color='black'>Comment Sent To $username!"; } } ///////////// Sending The Comment They Sent /////////////////// ?> <html> <form method="post" action=""> <table width='80%' cellspacing='0' cellpadding='0' border='1' bordercolor='#000000'> <tr> <td> <p align="center">Comment To Send: <br> </td> </tr> <tr> <td> <textarea name="msg" cols="40" rows="8" id="msg"></textarea> </td> </tr> <tr> </td> <input type="submit" name="submit" value="Send Comment"> </td> </tr> </table> </form> </html> Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917548 Share on other sites More sharing options...
dean7 Posted September 13, 2009 Author Share Posted September 13, 2009 It showed the box where you right the comment but i didnt insert it into database.. Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917550 Share on other sites More sharing options...
ngreenwood6 Posted September 13, 2009 Share Posted September 13, 2009 did it echo the comment sent line? try echoing $ul to the page Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917553 Share on other sites More sharing options...
dean7 Posted September 13, 2009 Author Share Posted September 13, 2009 did it echo the comment sent line? try echoing $ul to the page No, its not echoing anything.. Ive try just echoing the userlevel "$ul" but that didnt work. Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917555 Share on other sites More sharing options...
ngreenwood6 Posted September 13, 2009 Share Posted September 13, 2009 try this then: <?php ///////////// Start Of New Code /////////////// ///////////// Add Comment On Profile ////////// include ("config.php"); include ("makelogin.php"); ////////////// Includes ////////////////// $username = $logged['username']; $ul = $logged['userlevel']; $msg=strip_tags($_POST['msg']); $date = gmdate('Y-m-d h:i:s'); ///////////// Starting Varibals ////////////////// $query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1"); $fetch=mysql_fetch_object($query); ///////////// Querys ///////////////////////// if ($_POST['submit']) { ///////////////////// Line 158 is The One BELOW This ////////////////////////////////// mysql_query("INSERT INTO pmessages ('id','title','from','message','date','unread') VALUES ('','Profile Comment','$username','$msg','$date','unread')"); echo "<font color='black'>Comment Sent To $username!"; } ///////////// Sending The Comment They Sent /////////////////// ?> <html> <form method="post" action=""> <table width='80%' cellspacing='0' cellpadding='0' border='1' bordercolor='#000000'> <tr> <td> <p align="center">Comment To Send: <br> </td> </tr> <tr> <td> <textarea name="msg" cols="40" rows="8" id="msg"></textarea> </td> </tr> <tr> </td> <input type="submit" name="submit" value="Send Comment"> </td> </tr> </table> </form> </html> Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917557 Share on other sites More sharing options...
dean7 Posted September 13, 2009 Author Share Posted September 13, 2009 I didnt do nothing different, But when you press submit it just refreashs :S Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917558 Share on other sites More sharing options...
ngreenwood6 Posted September 13, 2009 Share Posted September 13, 2009 did it echo the comment line this time? did it insert the data? Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917560 Share on other sites More sharing options...
ngreenwood6 Posted September 13, 2009 Share Posted September 13, 2009 Sorry its late and i am slipping lol. try this and if it gives you an error tell me what it was: <?php ///////////// Start Of New Code /////////////// ///////////// Add Comment On Profile ////////// include ("config.php"); include ("makelogin.php"); ////////////// Includes ////////////////// $username = $logged['username']; $ul = $logged['userlevel']; $msg=strip_tags($_POST['msg']); $date = gmdate('Y-m-d h:i:s'); ///////////// Starting Varibals ////////////////// $query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1"); $fetch=mysql_fetch_object($query); ///////////// Querys ///////////////////////// if ($_POST['submit']) { ///////////////////// Line 158 is The One BELOW This ////////////////////////////////// mysql_query("INSERT INTO pmessages (id,title,from,message,date,unread) VALUES('','Profile Comment','$username','$msg','$date','unread')") or die(mysql_error()); echo "<font color='black'>Comment Sent To $username!"; } ///////////// Sending The Comment They Sent /////////////////// ?> <html> <form method="post" action=""> <table width='80%' cellspacing='0' cellpadding='0' border='1' bordercolor='#000000'> <tr> <td> <p align="center">Comment To Send: <br> </td> </tr> <tr> <td> <textarea name="msg" cols="40" rows="8" id="msg"></textarea> </td> </tr> <tr> </td> <input type="submit" name="submit" value="Send Comment"> </td> </tr> </table> </form> </html> Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917561 Share on other sites More sharing options...
dean7 Posted September 13, 2009 Author Share Posted September 13, 2009 When i click reply it show this: 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 'from,message,date,unread) VALUES('','Profile Comment','dean7','fdgdfg','2009-09-' at line 1 Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917562 Share on other sites More sharing options...
dean7 Posted September 13, 2009 Author Share Posted September 13, 2009 also with the code <?php ///////////// Start Of New Code /////////////// ///////////// Add Comment On Profile ////////// include ("config.php"); include ("makelogin.php"); ////////////// Includes ////////////////// $username = $logged['username']; $ul = $logged['userlevel']; $msg=strip_tags($_POST['msg']); $date = gmdate('Y-m-d h:i:s'); ///////////// Starting Varibals ////////////////// $query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1"); $fetch=mysql_fetch_object($query); ///////////// Querys ///////////////////////// if ($_POST['submit']) { ///////////////////// Line 158 is The One BELOW This ////////////////////////////////// mysql_query("INSERT INTO pmessages ('id','title','from','message','date','unread') VALUES ('','Profile Comment','$username','$msg','$date','unread')"); echo "<font color='black'>Comment Sent To $username!"; } ///////////// Sending The Comment They Sent /////////////////// ?> <html> <form method="post" action=""> <table width='80%' cellspacing='0' cellpadding='0' border='1' bordercolor='#000000'> <tr> <td> <p align="center">Comment To Send: <br> </td> </tr> <tr> <td> <textarea name="msg" cols="40" rows="8" id="msg"></textarea> </td> </tr> <tr> </td> <input type="submit" name="submit" value="Send Comment"> </td> </tr> </table> </form> </html> It does echo who its sent to just dont insert it. Link to comment https://forums.phpfreaks.com/topic/174063-t-strings/#findComment-917563 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.