seanc722 Posted November 9, 2011 Share Posted November 9, 2011 Hello, I am not sure if you can help me or if this is the place but... I am running linux and php5.3.6 I am having problems that I did not experience on my Windows box and it has to do with arrays if ($answer['correct']) { (which contains 1 or 0) is throwing Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING removing the quotes works but just curious why it is not working and if there is a setting i can change Also $answers[] = $answer[id]; is throwing Parse error: syntax error, unexpected ']', expecting T_STRING or T_VARIABLE or T_NUM_STRING Thank you to anyone who might be able to help. Quote Link to comment https://forums.phpfreaks.com/topic/250789-associative-array/ Share on other sites More sharing options...
Pikachu2000 Posted November 9, 2011 Share Posted November 9, 2011 You'll need to post the 5 lines before and after the lines that indicate the errors. Don't retype it, just copy and paste it. Quote Link to comment https://forums.phpfreaks.com/topic/250789-associative-array/#findComment-1286710 Share on other sites More sharing options...
xyph Posted November 9, 2011 Share Posted November 9, 2011 If id is not a constant (see declare) then it should be written as $answer['id'], letting the parser know id is a string. There is nothing wrong with the code you have posted. The errors lie elsewhere. Quote Link to comment https://forums.phpfreaks.com/topic/250789-associative-array/#findComment-1286714 Share on other sites More sharing options...
seanc722 Posted November 9, 2011 Author Share Posted November 9, 2011 Thank you for the responses. I didn't think there was anything wrong with the code and with you confirming I just messed around in the file a little. I didn't actually change anything but I got it to work.. I dont know what it could have been... I just replaced spaces with spaces and brackets with brackets and quotes with quotes. Maybe a different encoded character somewhere? No clue... anyways thank you. Quote Link to comment https://forums.phpfreaks.com/topic/250789-associative-array/#findComment-1286732 Share on other sites More sharing options...
xyph Posted November 9, 2011 Share Posted November 9, 2011 Could have been one of those darn stylized quotes. This is a big issue when copying+pasting - something you should never do (not saying you do it ) What editor are you using? Quote Link to comment https://forums.phpfreaks.com/topic/250789-associative-array/#findComment-1286735 Share on other sites More sharing options...
seanc722 Posted November 9, 2011 Author Share Posted November 9, 2011 I actually tried looking for funky characters or differences under a few different ones but I like to use Kate. ...and it was a script I wrote and uploaded (from windows) then I was going to modify it, so I downloaded it (into linux). When I ran the local script it in my browser it was throwing all kinds of errors that it did not throw on windows nor on my web server (which is hosted under Linux). Having a bad day today so thought maybe I messed something up but... doesn't seem like the case. Maybe I try and download it again and see exactly where the problem was now that I know it wasnt me >> Quote Link to comment https://forums.phpfreaks.com/topic/250789-associative-array/#findComment-1286807 Share on other sites More sharing options...
xyph Posted November 9, 2011 Share Posted November 9, 2011 Something changed that file going from computer A to computer B. If not, either one machine wasn't reporting the errors, or they had wildly different build of PHP. Odd quotes can be hard to find if your editor uses a font that has the same appearance for “, ”, and ". Quote Link to comment https://forums.phpfreaks.com/topic/250789-associative-array/#findComment-1286809 Share on other sites More sharing options...
seanc722 Posted November 9, 2011 Author Share Posted November 9, 2011 What font do you code in? Just curious as I really want to switch to a nice monospace but can't find any that are to my liking. Quote Link to comment https://forums.phpfreaks.com/topic/250789-associative-array/#findComment-1286811 Share on other sites More sharing options...
xyph Posted November 9, 2011 Share Posted November 9, 2011 I use the default Courier New v5 at 10pt It's a little boring, but I've never had an issue with it. Quote Link to comment https://forums.phpfreaks.com/topic/250789-associative-array/#findComment-1286816 Share on other sites More sharing options...
kicken Posted November 10, 2011 Share Posted November 10, 2011 What font do you code in? Just curious as I really want to switch to a nice monospace but can't find any that are to my liking. I like the Proggy Clean set of fonts. Particularly the ones with the bold punctuation marks. Quote Link to comment https://forums.phpfreaks.com/topic/250789-associative-array/#findComment-1286915 Share on other sites More sharing options...
seanc722 Posted November 10, 2011 Author Share Posted November 10, 2011 Yea I was looking at that one. Inconsolata also looks nice Quote Link to comment https://forums.phpfreaks.com/topic/250789-associative-array/#findComment-1286917 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.