Jump to content

[SOLVED] So confused!!


almightyegg

Recommended Posts

I have this code that just won't insert the right values, yet there is no error message....

 

if($defender[id] != $mem[last1] && $defender[id] != $mem[last2] && $defender[id] != $mem[last3] && $defender[id] != $mem[last4] && $defender[id] != $mem[last5]){
$new1 = $defender[id];
$new2 = $mem[last1];
$new3 = $mem[last2];
$new4 = $mem[last3];
$new5 = $mem[last4];
$up = mysql_query("UPDATE users SET last1 = '$new1' and last2 = '$new2' and last3 = '$new3' and last4 = '$new4' and last5 = '$new5' WHERE id = '{$mem['id']}'") or die(mysql_error());
if(!$up){
echo "ERRORZ";
}
}

 

The first time I run this code it updates with $mem[id] instead of $defender[id] into $new1 so values are thus:

$new1 = 1;

$new2 = 0;

$new3 = 0;

$new4 = 0;

$new5 = 0;

 

But just before the SQL I echo them out they are correct ($new1 = 2;)

 

What's more if I run it again, all the values become 0 in the SQL when they should still be

$new1 = 2;

$new2 = 0;

$new3 = 0;

$new4 = 0;

$new5 = 0;

 

or if I changed the $defender[id] it should be

$new1 = newid;

$new2 = 2;

$new3 = 0;

$new4 = 0;

$new5 = 0;

 

but it still inserts as 0 for all 5 values!

 

I'm so so confused.....

Link to comment
https://forums.phpfreaks.com/topic/154045-solved-so-confused/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.