Topic: Stupid functions... (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=31737" title="Pages that link to Topic: Stupid functions... (Page 1 of 1)" rel="nofollow" >Topic: Stupid functions... <span class="small">(Page 1 of 1)</span>\

 
Ensellitis
Paranoid (IV) Inmate

From: Kansas City, MO , USA
Insane since: Feb 2002

IP logged posted posted 03-24-2010 05:27 Edit Quote

I have been fighting this for hours it seems...

I have this function:

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'");
}



It has an odd problem... If the person is level 0 or 1, the update happens right away. However, if they hit level 3, I have to refresh the list to see the update. Am I missing something here? Am I using the right method for this?

I'm at a loss...

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

IP logged posted posted 03-24-2010 10:13 Edit Quote

well, I don't see an obvious error, and I can't follow your 'see the update right away' description,
but I'd start this differently and remove the duplication.

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



->Tyberius Prime

Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

IP logged posted posted 03-25-2010 08:05 Edit Quote

Pardon my ignorance, but what is this code supposed to do?

revjx2
Obsessive-Compulsive (I) Inmate

From:
Insane since: Aug 2009

IP logged posted posted 03-26-2010 18:11 Edit Quote

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!

Ensellitis
Paranoid (IV) Inmate

From: Kansas City, MO , USA
Insane since: Feb 2002

IP logged posted posted 03-29-2010 05:09 Edit Quote

i think it was my debug script causing the problems. it works as it should now. thanks tyberious, you are still the man



Post Reply
 
Your User Name:
Your Password:
Login Options: Remember Me On This Computer
 
Your Text:
Loading...
Options: Show Signature
Enable Slimies
Enable Linkwords

« BackwardsOnwards »

Show Forum Drop Down Menu