Phpfr3ak Posted February 7, 2012 Share Posted February 7, 2012 Getting the following error Parse error: syntax error, unexpected T_AS in C:\Program Files\EasyPHP-5.3.3\www\public_html\PlayerRanks.php on line 22, really unsure as to why any insight please? Thanks $sql = "SELECT * FROM hitlist WHERE player_id = '$playerID'"; $que = mysql_query($sql) or die(mysql_error()); if (is_array($que['hit_id'] as $hits) { foreach ($que['hit_id'] as $hits) { //do somthing } } else Quote Link to comment https://forums.phpfreaks.com/topic/256583-unexpected-t_as/ Share on other sites More sharing options...
Deoctor Posted February 7, 2012 Share Posted February 7, 2012 Try this $sql = "SELECT * FROM hitlist WHERE player_id = '".$playerID."'"; Quote Link to comment https://forums.phpfreaks.com/topic/256583-unexpected-t_as/#findComment-1315358 Share on other sites More sharing options...
PFMaBiSmAd Posted February 7, 2012 Share Posted February 7, 2012 I recommend that you look at the at's as's in your code. Only php foreach() statements have them. Edit: fixed typo Quote Link to comment https://forums.phpfreaks.com/topic/256583-unexpected-t_as/#findComment-1315359 Share on other sites More sharing options...
Phpfr3ak Posted February 7, 2012 Author Share Posted February 7, 2012 I dont know what im looking for is the honest truth, i just want to look it to see if $addIDs_ary is already set as hit_id in the table hitlist where the players_id = $playersID,, i get how to do it normally buy doing it for multiple results just baffles my mind Quote Link to comment https://forums.phpfreaks.com/topic/256583-unexpected-t_as/#findComment-1315361 Share on other sites More sharing options...
Deoctor Posted February 7, 2012 Share Posted February 7, 2012 Is this a duplicate post? I guess u have already placed one post asking the same question. Quote Link to comment https://forums.phpfreaks.com/topic/256583-unexpected-t_as/#findComment-1315362 Share on other sites More sharing options...
PFMaBiSmAd Posted February 7, 2012 Share Posted February 7, 2012 You are getting a php syntax error on a specific line in your code, indicating an unexpected AS (the T in T_AS means TOKEN - i.e. php is a parsed, Tokenized, interpreted language) was found on that line. If you look at that actual line in your code, you will see that you have used an as $hits inside an is_array statement. Since the purpose of an is_array statement is to test if the supplied argument is an array, why do you have the as $hits in there? Sorry to be blunt again, but you simply must think about what you are doing when you write and debug your code. You must also lookup what each statement does. is_array — Finds whether a variable is an array. The only thing is_array takes as a parameter is a variable name that may or may not be an array. Quote Link to comment https://forums.phpfreaks.com/topic/256583-unexpected-t_as/#findComment-1315446 Share on other sites More sharing options...
litebearer Posted February 7, 2012 Share Posted February 7, 2012 Perhaps my caffeine hasn't kicked in yet; but isn't $que = mysql_query($sql) or die(mysql_error()); simply the resource id and as yet NOTHING as far as database content has been returned yet? ie while($row= mysql_fetch_array) { yada yada yada } Quote Link to comment https://forums.phpfreaks.com/topic/256583-unexpected-t_as/#findComment-1315456 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.