Jump to content

Arrays simply refuse to work


Arkazex

Recommended Posts

Hi,

I've tried many times, but I have been unsucsessful in determining why this code won't work.  I've tried everything, but still no luck.

 

$users = array(
  "dog" => "asdfghjkl",
  "cat" => "qwertyuiop",
);

but I still get this error every single time:

 

Parse error: syntax error, unexpected ')', expecting ']' in /www/zxq.net/a/r/k/arkazex/htdocs/UserLogin/Login/Login.php on line 10

and If I try to change the ");" on the last line to "];" the error switches saying that's wrong as well.  I've been stuck for quite a while, and any help would be greatly appreciated.  Thanks,

 

Arkazex.

Link to comment
https://forums.phpfreaks.com/topic/276363-arrays-simply-refuse-to-work/
Share on other sites

You shouldn't have a comma after the last array item, however that would not cause the error you are getting. Your error most likely comes from some other bit of code above that section, you need to post more of the code, or look higher.

 

Just because PHP says an error is on line XX does not mean that is where the error actually is. That is just how far PHP managed to get before the code stopped making sense. Some problems such as forgetting quotes or brackets can result in an error not being reported until much later in the code than where your problem actually is.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.