Jump to content

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

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

Link to comment
https://forums.phpfreaks.com/topic/256583-unexpected-t_as/#findComment-1315361
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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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