Jump to content

associative array


seanc722

Recommended Posts

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 >>

 

Link to comment
Share on other sites

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 ".

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.