remzone Posted June 22, 2006 Share Posted June 22, 2006 HI all, I am trying to learn PHP and MYSql been doing it a grand total of 4 Days and enjoying it tbh. I have been playing with superglobals to get used to them but have come across a problem with them which you guys will prob think it's peice of cake but I got to start somewhere eh [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] .<?php echo "Hi! Your IP is: $_SERVER['REMOTE_ADDR']"; ?>Produces : Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING.I tried something outta my own head but dunno if I did right but still it didn't wortk anywayz.<?php$sip = $_SERVER['REMOTE_ADDR'];echo $sip;?>With this I get a variable not assigned error but as far as I was awear superglobals are predfined so didn't think I had to assign a value to $_SERVER, unless there is a problem with assigning $sip the value of a superglobal?I've tried to find my php.ini to see if globals are switched off but a, they have it hidden i guess and b, I thought that superglobals would still work with that switched off?any help would be appreciated [img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /] Quote Link to comment https://forums.phpfreaks.com/topic/12619-superglobals-error/ Share on other sites More sharing options...
.josh Posted June 22, 2006 Share Posted June 22, 2006 idk what the problem is, but it's not with your code. at least, the 2nd one. i understand the parse error in the first, but the 2nd one is okay. yes, it should work even if globals are off. this is more of a wild stab in the dark than anything, but try doing <?phpvar $sip;$sip = $_SERVER['REMOTE_ADDR'];echo $sip;?>i know it shouldn't be necessary, but perhaps there is some setting in .ini that's turned off or something. wish i could help more... Quote Link to comment https://forums.phpfreaks.com/topic/12619-superglobals-error/#findComment-48396 Share on other sites More sharing options...
shortj75 Posted June 22, 2006 Share Posted June 22, 2006 what type of server are you useing and what is the name of it maybe some one here is useing the same type and can help you find you php.ini so you can check and change what you need Quote Link to comment https://forums.phpfreaks.com/topic/12619-superglobals-error/#findComment-48399 Share on other sites More sharing options...
wildteen88 Posted June 22, 2006 Share Posted June 22, 2006 Run this code:[code]<?phgphpinfo ();?>[/code]Look for a line called [b]Configuration File (php.ini) Path[/b] this will show you the location of the php.ini file. NOTE: if you're on a shared hosting account it is likely you will not be able to access the php.ini to edit it.Secoundly scroll down a bit further and find [b]register_globals[/b] both columns should state Off, if the right column is set to on then you have register_globals on and thus you cannot use superglobals. Instead you'll have to do this:[code]echo 'your ip is: ' . $REMOTE_ADDR;[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12619-superglobals-error/#findComment-48416 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.