Jump to content

unexpected T_AS


Phpfr3ak

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/256583-unexpected-t_as/
Share on other sites

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.

 

 

Link to comment
https://forums.phpfreaks.com/topic/256583-unexpected-t_as/#findComment-1315446
Share on other sites

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
}

 

Link to comment
https://forums.phpfreaks.com/topic/256583-unexpected-t_as/#findComment-1315456
Share on other sites

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.