Ptsface12 Posted July 21, 2011 Share Posted July 21, 2011 Hello, I am trying to use PHP_SELF in this form, however I get the error at the botom of the page. Any help is brilliant! <head> <link type="text/css" rel="stylesheet" href="http://habbtalk.com/Version2/_content/style.css" /> <style> .divider { border-bottom: 1px solid #ADADAD; font-family: "Tahoma", Arial, Verdana; margin-bottom: 5px; color: #ADADAD; font-weight: bold; font-size: 13px; width: 440px; } form { padding: 0; margin: 0; } .wrapper { background-color: #fcfcfc; width: 300px; margin: auto; padding: 5px; margin-top: 15px; } .good, .bad { padding: 5px; margin-bottom: 5px; } .good strong, .bad strong { font-size: 12px; font-weight: bold; } .good { background-color: #d9ffcf; border-color: #ade5a3; color: #1b801b; } .bad { background-color: #ffcfcf; border-color: #e5a3a3; color: #801b1b; } input, select, textarea { border: 1px #e0e0e0 solid; border-bottom-width: 2px; padding: 3px; } input { width: 170px; } input.button { width: auto; cursor: pointer; background: #eee; } select { width: 176px; } textarea { width: 288px; } label { display: block; padding: 3px; } </style> </head> <div class="content_container"> <div class="center_pink_header"> <img src="scripts/header.php?size=7&width=1&text=ADD YOURSELF TO THE SPOTLIGHT!&colour=pink" alt="Add Yourself!" /> </div> <div class="center_box"> <br/> <div class="textContainer"><?php include("../_spotlight/config.php"); if ($_POST[spotlight]) { $username = $_POST[username]; $hotel = $_POST[hotel]; if($username==NULL) { echo "Whoops! You left something blank. Please go back and rectify this problem."; }else{ $checkuser = mysql_query("SELECT username FROM users WHERE username='$username'"); $checkuser2 = mysql_num_rows($checkuser); if ($checkuser2>0) { echo "Uh-Oh! A user with this name has already been added."; }else{ $username = htmlspecialchars($username); $hotel = htmlspecialchars($hotel); $query = mysql_query("INSERT INTO users (username, hotel) VALUES('$username','$hotel')"); echo "<div class=\"good\">"; echo "<strong>Success</strong>"; echo "</div>"; }}} else { echo ("<form method=\"POST\" action=\"$_SERVER['PHP_SELF']\" ><center> <b>user Name:</br> <input type=\"text\" class=\"input\" size=\"25\" maxlength=\"50\" name=\"username\"><br /> <b>Hotel:</br> <select size=\"1\" name=\"hotel\" class=\"select\"> <option value=\".com\">user International</option> <option value=\".ca\">user CA</option> <option value=\".com.au\">user AU</option> </select> <br /> <br> <input name=\"spotlight\" type=\"submit\" class=\"button\" value=\"Add Me to the Spotlight!\"> </center> </form>"); } ?> <br/> <br/> </div> </div> <div class="center_box_bottom"></div> The error I get is: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/habbofea/public_html/v1/_content/add.php on line 140 Any help appreciated! Best Wishes, Ptsface12 Quote Link to comment https://forums.phpfreaks.com/topic/242559-php_self-in-echo/ Share on other sites More sharing options...
premiso Posted July 21, 2011 Share Posted July 21, 2011 It would make it a ton easier if you pointed out what line is 140. Quote Link to comment https://forums.phpfreaks.com/topic/242559-php_self-in-echo/#findComment-1245724 Share on other sites More sharing options...
Ptsface12 Posted July 21, 2011 Author Share Posted July 21, 2011 Hello, Sorry; It's the form where it echo's out: echo ("<form method=\"POST\" action=\"$_SERVER['PHP_SELF'];\"><center> Best Wishes, Ptsface12 Quote Link to comment https://forums.phpfreaks.com/topic/242559-php_self-in-echo/#findComment-1245726 Share on other sites More sharing options...
cs.punk Posted July 21, 2011 Share Posted July 21, 2011 Hello, Sorry; It's the form where it echo's out: echo ("<form method=\"POST\" action=\"$_SERVER['PHP_SELF'];\"><center> Best Wishes, Ptsface12 Don't use $_SERVER ['PHP_SELF']... http://markjaquith.wordpress.com/2009/09/21/php-server-vars-not-safe-in-forms-or-links/ But to answer your question... Firstly you have three closing brakects two lines above 140 }}}... Secondly echo ("<form method=\"POST\" action=\"$_SERVER['PHP_SELF'];\"><center> You added a semicolon at the end of $_SERVER['PHP_SELF']... Quote Link to comment https://forums.phpfreaks.com/topic/242559-php_self-in-echo/#findComment-1245729 Share on other sites More sharing options...
Ptsface12 Posted July 21, 2011 Author Share Posted July 21, 2011 Hello, Thanks, but now I get the following problem: Parse error: syntax error, unexpected T_ELSE in /home/habbofea/public_html/v1/_content/add.php on line 135 Line 135: else { Quote Link to comment https://forums.phpfreaks.com/topic/242559-php_self-in-echo/#findComment-1245735 Share on other sites More sharing options...
Ptsface12 Posted July 21, 2011 Author Share Posted July 21, 2011 Is this because there's to many of something? Quote Link to comment https://forums.phpfreaks.com/topic/242559-php_self-in-echo/#findComment-1245742 Share on other sites More sharing options...
TOA Posted July 21, 2011 Share Posted July 21, 2011 Is this because there's to many of something? Or not enough of it's matching tag.. You probably needed that 3rd } that was referred to above. Try adding it back in and see if that helps Quote Link to comment https://forums.phpfreaks.com/topic/242559-php_self-in-echo/#findComment-1245744 Share on other sites More sharing options...
Ptsface12 Posted July 21, 2011 Author Share Posted July 21, 2011 Nope, I still get errors unfortunately. Quote Link to comment https://forums.phpfreaks.com/topic/242559-php_self-in-echo/#findComment-1245748 Share on other sites More sharing options...
TOA Posted July 21, 2011 Share Posted July 21, 2011 Nope, I still get errors unfortunately. K. Worth a shot. I just looked at your op, and line 140, when your echoing the $_SERVER['PHP_SELF'], since you're echoing it in double quotes, you don't need the single quotes inside the brackets so try echo "$_SERVER[php_SELF]" Posting the most recent code might help too Quote Link to comment https://forums.phpfreaks.com/topic/242559-php_self-in-echo/#findComment-1245751 Share on other sites More sharing options...
Ptsface12 Posted July 21, 2011 Author Share Posted July 21, 2011 hello, I don't quite get what your implying, could you put it into the following format please; echo ("<form method=\"POST\" action="whatyourimplying here"> Thanks for your help though! Best Wishes, Ptsface12 Quote Link to comment https://forums.phpfreaks.com/topic/242559-php_self-in-echo/#findComment-1245760 Share on other sites More sharing options...
Ptsface12 Posted July 21, 2011 Author Share Posted July 21, 2011 No worries, I figured out what you meant. The script works now, thanks mate! Quote Link to comment https://forums.phpfreaks.com/topic/242559-php_self-in-echo/#findComment-1245762 Share on other sites More sharing options...
TOA Posted July 21, 2011 Share Posted July 21, 2011 No worries, I figured out what you meant. The script works now, thanks mate! Awesome Quote Link to comment https://forums.phpfreaks.com/topic/242559-php_self-in-echo/#findComment-1245815 Share on other sites More sharing options...
premiso Posted July 21, 2011 Share Posted July 21, 2011 To really answer your question, it is because you were including an associative array inside of the echo. The single quotes mess it up, in cases such as that use braces {} to include the variable. echo ("<form method=\"POST\" action=\"{$_SERVER['PHP_SELF']}\"><center>"); WOuld have solved it. Quote Link to comment https://forums.phpfreaks.com/topic/242559-php_self-in-echo/#findComment-1245846 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.