1-7 for loop only works with 1, not 2+?
Posted: Thu Oct 16, 2008 1:11 pm
The following for loop gets stuck at '1'. Skipping 1 and starting at 2 and other things hasn't helped. It just won't do anything from 2 or greater. This for loop is killing me right now. What have I goofed up in the logic?
Code: Select all
for ($every = 1; $every <= 7; $every += 1)
{
$cat = 'cat_'.$every;
if (isset($_POST[$cat]))
{
$mysql_game_add_tag = mysql_query("INSERT INTO `gamer`.`game_category` (`category_id`, `game_id`) VALUES ('".$_POST['cat_'.$every]."', '".$game_id."')");
if (!$mysql_game_add_tag) {$_SESSION['status'] = '<b>Error occurred adding tags for a game to the database:</b> '. mysql_error(); header("location:".$truepage."?error"); exit();}
else {return "success";}
}
else {return "success";}
}