Weird...why won't it work?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
HaVoC
Forum Commoner
Posts: 83
Joined: Sat Feb 07, 2004 7:20 am
Location: Smiths Falls, CA

Weird...why won't it work?

Post 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 :?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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 ;))
User avatar
HaVoC
Forum Commoner
Posts: 83
Joined: Sat Feb 07, 2004 7:20 am
Location: Smiths Falls, CA

Post by HaVoC »

The little things that kill people. I knew that. It wasn't a typo. I was just being stupid.
Post Reply