![]() Topic awaiting preservation: Stupid functions... (Page 1 of 1) |
|
|---|---|
|
Paranoid (IV) Inmate From: Kansas City, MO , USA |
posted 03-24-2010 05:27
I have been fighting this for hours it seems... code: function levelwith3up($id,$threeup1db,$threeup2db,$threeup3db) {
if($threeup1db == 0 && $threeup2db == 0 && $threeup3db == 0)
mysql_query("UPDATE members SET level = 1 WHERE ID = '$id'");
if($threeup1db == 1 && $threeup2db == 1 && $threeup3db == 1)
mysql_query("UPDATE members SET level = 2 WHERE ID = '$id'");
if($threeup1db == 2 && $threeup2db == 2 && $threeup3db == 2)
mysql_query("UPDATE members SET level = 3 WHERE ID = '$id'");
if($threeup1db == 3 && $threeup2db == 3 && $threeup3db == 3)
mysql_query("UPDATE members SET level = 4 WHERE ID = '$id'");
if($threeup1db == 4 && $threeup2db == 4 && $threeup3db == 4)
mysql_query("UPDATE members SET level = 5 WHERE ID = '$id'");
}
|
|
Maniac (V) Mad Scientist with Finglongers From: Germany |
posted 03-24-2010 10:13
well, I don't see an obvious error, and I can't follow your 'see the update right away' description, code: function levelwith3up($id,$threeup1db,$threeup2db,$threeup3db) {
if (($threeup1db == $threeup2db && $threeup1db == $threeup3db) &&
($threeup1db >=0 && $threeup1db <= 4)
{
$new_val = intval($threeup1db) + 1;
$id = mysql_real_escape_string($id); //seriously, does PHP still not have a template based sql engine???!
mysql_query("UPDATE members SET level = $new_val WHERE ID = '$id'");
}
else
{
error_occurred...
}
} |
|
Maniac (V) Mad Scientist From: 127 Halcyon Road, Marenia, Atlantis |
posted 03-25-2010 08:05
Pardon my ignorance, but what is this code supposed to do? |
|
Obsessive-Compulsive (I) Inmate From: |
posted 03-26-2010 18:11
I was going to say about escaping $id or otherwise checking that it's not something nasty you're not expecting, beyond that I don't see why it would behave differently! |
|
Paranoid (IV) Inmate From: Kansas City, MO , USA |
posted 03-29-2010 05:09
i think it was my debug script causing the problems. it works as it should now. thanks tyberious, you are still the man |