Strange occurence with variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
roondog
Forum Newbie
Posts: 18
Joined: Sun Jul 22, 2007 11:56 am

Strange occurence with variables

Post 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.
xitura
Forum Newbie
Posts: 20
Joined: Fri Sep 07, 2007 11:25 am

Post by xitura »

For is a reserved mysql word.
Post Reply