Jump to content

[SOLVED] So confused!!


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());
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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.