ed.237 Posted April 30, 2009 Share Posted April 30, 2009 Hey guys, i'm a newbie to php coding and having so difficulties getting my code to work as i wish. My code is listed below: foreach ($races as $race) { $horseresult = mysql_query("SELECT DISTINCT * FROM Horse, RaceHorse WHERE Horse.HorseID = RaceHorse.HorseID AND ".$race." = RaceHorse.RaceID"); echo "</br>"; echo "Dealing with race id: $race"; echo "</br>"; $theloc = array_search($race, $races); echo "THE $theloc </br>"; $races[$theloc] = $race => array(); print_r($races); echo "</br>"; while($horsename = mysql_fetch_array($horseresult)) { $thehorse = $horsename["HorseName"]; array_push($races[$theloc],$thehorse); } echo "</br>"; } It doesn't like $races[$theloc] = $race => array(); it produces the error Parse error: syntax error, unexpected T_DOUBLE_ARROW in /u/u/ek237/public_html/horse_betting/final/bets/tempmakebet.php on line 45 I want this to work so the the race id (which is $race) we are looking at in the array full of races id ($races) is reassigned to be a key holding a value which is an array . Any ideas on how to overcome this problem, maybe an alternative way to doing this?? Thanks a bunch! Quote Link to comment https://forums.phpfreaks.com/topic/156274-unexpected-t_double_arrow-error-when-trying-to-modify-an-array/ 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.