Nikki-M Posted November 23, 2008 Share Posted November 23, 2008 Hello everybody. Sorry, quite new to PHP; can somebody take a look at this little bit of code and explain why I am getting Parse error: syntax error, unexpected '[' <?php for ($i=0;$i<count($raw_wind_dir);$i++) { $sin_direction[] = sin(deg2rad($raw_wind_dir[$i])); $cos_direction[] = cos(deg2rad($raw_wind_dir[$i])); ?> } Many thanks for reading Regards Nikki Link to comment https://forums.phpfreaks.com/topic/133908-unexpected-problem/ Share on other sites More sharing options...
dezkit Posted November 23, 2008 Share Posted November 23, 2008 <?php for ($i=0;$i<count($raw_wind_dir);$i++) { $sin_direction[] = sin(deg2rad($raw_wind_dir[$i])); $cos_direction[] = cos(deg2rad($raw_wind_dir[$i])); } ?> Link to comment https://forums.phpfreaks.com/topic/133908-unexpected-problem/#findComment-697037 Share on other sites More sharing options...
Nikki-M Posted November 23, 2008 Author Share Posted November 23, 2008 Hi Dezkit Thanks for your reply, however i only included the php tags in the code sample to make the colours look nicer on this forum. The brace in my code is in the correct place. Regards Nikki Link to comment https://forums.phpfreaks.com/topic/133908-unexpected-problem/#findComment-697057 Share on other sites More sharing options...
DarkWater Posted November 23, 2008 Share Posted November 23, 2008 Your code is yielding no syntax errors when I check it. Link to comment https://forums.phpfreaks.com/topic/133908-unexpected-problem/#findComment-697060 Share on other sites More sharing options...
Mark Baker Posted November 23, 2008 Share Posted November 23, 2008 Do $sin_direction and $cos_direction already exist: and if so, what datatype are they? Link to comment https://forums.phpfreaks.com/topic/133908-unexpected-problem/#findComment-697067 Share on other sites More sharing options...
premiso Posted November 23, 2008 Share Posted November 23, 2008 It is obvious we need to see more code. It could be in the 2 functions you call on the lines etc. post more code and your question may be solved. In that code there are no errors. Link to comment https://forums.phpfreaks.com/topic/133908-unexpected-problem/#findComment-697084 Share on other sites More sharing options...
Mchl Posted November 23, 2008 Share Posted November 23, 2008 You should get line number, where the error is encountered. Show us which line it is, and if possible post also a few lines above this line. Link to comment https://forums.phpfreaks.com/topic/133908-unexpected-problem/#findComment-697089 Share on other sites More sharing options...
Nikki-M Posted November 23, 2008 Author Share Posted November 23, 2008 Thanks to everyone that has replied to my post. I've now fixed the problem - I had a missing brace earlier in the code :-( Must learn to look harder at my code before wasting you good peoples time :-) Regards Nikki Link to comment https://forums.phpfreaks.com/topic/133908-unexpected-problem/#findComment-697109 Share on other sites More sharing options...
Mchl Posted November 23, 2008 Share Posted November 23, 2008 Using editor that highlights matching braces (parentheses, quotes, etc) sure saves a lot of time. Link to comment https://forums.phpfreaks.com/topic/133908-unexpected-problem/#findComment-697113 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.