Page 1 of 1

Strange occurence with variables

Posted: Fri Sep 07, 2007 8:22 am
by roondog
i've managed to get this script working almost perfectly.


Code: Select all

<?php 

$con = mysql_connect ('localhost', '******', '******'); 

if (!$con) 
  { 
  die('Could not connect: ' . mysql_error()); 
  } 
mysql_select_db("roondog_news", $con); 

$ht1 = $_POST['hometeam1']; 
$at1 = $_POST['awayteam1']; 
$ht1s = $_POST['hometeam1_score']; 
$at1s = $_POST['awayteam1_score']; 

if (isset($ht1s)) { 

mysql_query("UPDATE league SET played = played +1 
WHERE teamname = '$ht1'"); 
mysql_query("UPDATE league SET played = played +1 
WHERE teamname = '$at1'"); 


if ($ht1s > $at1s) { 

mysql_query("UPDATE league SET won = won +1 
WHERE teamname = '$ht1'"); 
mysql_query("UPDATE league SET lost = lost + 1 
WHERE teamname = '$at1'"); 
mysql_query("UPDATE league SET points = points + 3 
WHERE teamname = '$ht1'"); 

}else if ($ht1s < $at1s) { 

mysql_query("UPDATE league SET lost = lost +1 
WHERE teamname = '$ht1'"); 
mysql_query("UPDATE league SET won = won +1 
WHERE teamname = '$at1'"); 
mysql_query("UPDATE league SET points = points + 3 
WHERE teamname = '$at1'"); 


}else{ 

mysql_query("UPDATE league SET drawn = drawn +1 
WHERE teamname = '$ht1'"); 
mysql_query("UPDATE league SET drawn = drawn +1 
WHERE teamname = '$at1'"); 
mysql_query("UPDATE league SET points = points +1 
WHERE teamname = '$ht1'"); 
mysql_query("UPDATE league SET points = points +1 
WHERE teamname = '$at1'"); 

} 


/*from here to the end the table isn't updating 
*/ 


{ 
mysql_query("UPDATE league SET for = for +$ht1s 
WHERE teamname = '$ht1'"); 
mysql_query("UPDATE league SET away = away +$at1s 
WHERE teamname = '$ht1'"); 
mysql_query("UPDATE league SET for = for +$at1s
WHERE teamname = '$at1'"); 
mysql_query("UPDATE league SET away = away +$ht1s
WHERE teamname = '$at1'"); 
} 

} 
{ 
mysql_query("UPDATE league SET goaldif = for - away"); 
} 
mysql_close($con); 

?>
The problem is the $ht1s and $at1s variables aren't updating the for and away collumns but are working in the if statements above. I've done another script that just echoes the variables and they don't show up. Not sure why this is happening.

Posted: Fri Sep 07, 2007 11:29 am
by xitura
For is a reserved mysql word.