Arkazex Posted March 31, 2013 Share Posted March 31, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/276363-arrays-simply-refuse-to-work/ Share on other sites More sharing options...
kicken Posted March 31, 2013 Share Posted March 31, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/276363-arrays-simply-refuse-to-work/#findComment-1422169 Share on other sites More sharing options...
Arkazex Posted March 31, 2013 Author Share Posted March 31, 2013 (edited) The only code above that is <?php EDIT: I noticed that If I comment out the entire rest of my page, the error goes away, but adding anything beneath it will cause the error to return.... Edited March 31, 2013 by Arkazex Quote Link to comment https://forums.phpfreaks.com/topic/276363-arrays-simply-refuse-to-work/#findComment-1422170 Share on other sites More sharing options...
Arkazex Posted March 31, 2013 Author Share Posted March 31, 2013 Well, I fixed it. Like you said, it was reporting the error at the wrong point. The error was actually being caused by a missing "]" in a completely diferent part of the script, and just linking to the wrong area. Quote Link to comment https://forums.phpfreaks.com/topic/276363-arrays-simply-refuse-to-work/#findComment-1422175 Share on other sites More sharing options...
Barand Posted April 1, 2013 Share Posted April 1, 2013 if all that was above those lines was "<?php" then it looks like you posted lines 2-5 but the error message said line 10. Had you thought of looking there? Quote Link to comment https://forums.phpfreaks.com/topic/276363-arrays-simply-refuse-to-work/#findComment-1422182 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.