Johng123 Posted January 11, 2010 Share Posted January 11, 2010 I have no idea why I matched up all the "}" yet still get the error. <html> <body> <?php include("/home/a1790778/public_html/include/session.php"); global $database; $friend_file = 'friends.txt'; $friend_code = $_POST[fcode]; $friend_content = file_get_contents($friend_file); if(isset($_POST['fcode'])) { $pos = strpos($friend_content, $_POST['fcode']); if ($pos === false) { $friend_content = $friend_content . "\r\n" . $friend_code; if(file_put_contents($friend_file,$friend_content)) { print $friend_code . ' has been added to the friends file.<hr />'; } } else print $friend_code . ' is already on the list!<hr />'; } $q = "SELECT username,userlevel,email,timestamp " ."FROM ".TBL_USERS." ORDER BY userlevel DESC,username"; $result = $database->query($q); $num_rows = mysql_numrows($result); for($i=0; $i<$num_rows; $i++) { $uname = mysql_result($result,$i,"username"); $friend_file = "/home/a1790778/public_html/FriendCodes/".$uname.".".txt;; $friend_content = file_get_contents($friend_file); if($pos === false) { $pos = strpos($friend_content, $_POST['fcode']); $friend_content = $friend_content . "\r\n" . $friend_code; file_put_contents($friend_file,$friend_content) }} ?> <br><br><br><br> <a href="main.php">Return to Site</a> <br><br><br><br><br><br> <div style="font-size:0px; position:absolute; width:0px; height:0px; color:#000000; z-index:-1; overflow:hidden;"><xmp></body></xmp></div> <script type='text/javascript'> document.write('</bo'); document.write('dy>'); </script> </html> Link to comment https://forums.phpfreaks.com/topic/187999-parse-error-syntax-error-unexpected-in-homea1790778public_htmladdcode/ Share on other sites More sharing options...
calmchess Posted January 11, 2010 Share Posted January 11, 2010 else print $friend_code . ' is already on the list!<hr />'; } needs a { in front of else Link to comment https://forums.phpfreaks.com/topic/187999-parse-error-syntax-error-unexpected-in-homea1790778public_htmladdcode/#findComment-992508 Share on other sites More sharing options...
Johng123 Posted January 11, 2010 Author Share Posted January 11, 2010 else print $friend_code . ' is already on the list!<hr />'; } needs a { in front of else I don't wanna say your wrong but I am pretty sure if it just does one thing in the else it does not need a bracket either way I think there is a problem with the last if statement or something because when I remove it then it works, but I need that statement Link to comment https://forums.phpfreaks.com/topic/187999-parse-error-syntax-error-unexpected-in-homea1790778public_htmladdcode/#findComment-992509 Share on other sites More sharing options...
calmchess Posted January 11, 2010 Share Posted January 11, 2010 but doesn't it have an end bracket? Link to comment https://forums.phpfreaks.com/topic/187999-parse-error-syntax-error-unexpected-in-homea1790778public_htmladdcode/#findComment-992510 Share on other sites More sharing options...
calmchess Posted January 11, 2010 Share Posted January 11, 2010 dont you need a ; on file_put_contents($friend_file,$friend_content) Link to comment https://forums.phpfreaks.com/topic/187999-parse-error-syntax-error-unexpected-in-homea1790778public_htmladdcode/#findComment-992513 Share on other sites More sharing options...
Johng123 Posted January 11, 2010 Author Share Posted January 11, 2010 dont you need a ; on file_put_contents($friend_file,$friend_content) wow that was it i hate myself lol Link to comment https://forums.phpfreaks.com/topic/187999-parse-error-syntax-error-unexpected-in-homea1790778public_htmladdcode/#findComment-992514 Share on other sites More sharing options...
trq Posted January 11, 2010 Share Posted January 11, 2010 This line also needs changing.... $friend_file = "/home/a1790778/public_html/FriendCodes/".$uname.".".txt;; to $friend_file = "/home/a1790778/public_html/FriendCodes/".$uname.".txt"; If you indented your code consistently any missing brace errors would become clear. Link to comment https://forums.phpfreaks.com/topic/187999-parse-error-syntax-error-unexpected-in-homea1790778public_htmladdcode/#findComment-992515 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.