Page 1 of 1

Weird...why won't it work?

Posted: Mon Mar 01, 2004 3:03 pm
by HaVoC

Code: Select all

<?php
$query = "SELECT lastgame FROM ldu_users WHERE user_name = '".$_POST['winner']."'"; 

$result = MySQL_query($query);
While( $rows = MySQL_fetch_array($result) ) {
$lg = $rows['lastgame'];
if ($lg = $_POST['loser']){
echo "<br>The last game you played was against this person. This game does not count!";
}else{
MySQL_query("UPDATE ldu_users SET lastgame = '".$_POST['winner']."' WHERE user_name = '".$_POST['loser']."'");
MySQL_query("UPDATE ldu_users SET lastgame = '".$_POST['loser']."' WHERE user_name = '".$_POST['winner']."'");
}
}
?>
OK, I can't seem to get this to work. Anybody know what I'm doing wrong?
All it says is that the game was against this person. It doesn't count. When really in the database, that's wrong :?

Posted: Mon Mar 01, 2004 3:07 pm
by markl999
if ($lg = $_POST['loser']){ should be if ($lg == $_POST['loser']){

= is an assignment,
== is a comparison
(just in case it wasn't a typo ;))

Posted: Mon Mar 01, 2004 4:47 pm
by HaVoC
The little things that kill people. I knew that. It wasn't a typo. I was just being stupid.