Jump to content

A very tricky mystery...


Ender22

Recommended Posts

???

I have one of those problems where my code works perfectly on my localhost, however when I upload it to my webhoster something very strange and unexplainable happens. Its quite the mystery that has been racking my brain all day. Heres whats going on.

 

My Code:

 

 
               if($canvote)
  {
	  $rating = $row_Recordset1['EpicPoints'];
	  $rating+=$vote;
	  $t = "UPDATE epiclink SET EpicPoints = $rating WHERE ID=$colname_Recordset1"; 
	  mysql_query($t, $EpicDatabase) or die('Error, query failed'); 
  }

 

Now on my localhost this code grabs the entry's current Epic Points in $rating, ads in the value for $vote and updates properly.

On my webhost it does the same except it adds double the points

 

Now obviously my first guess was that this code is getting executed twice. This doesnt seem to be the case as I added an alert("going here") and tested it out. The alert was only ever called once.

 

Another possibility is that $rating is getting calculated improperly before the update is being called. But I did an alert($rating) and verified that the value is correct.

 

Some additional info. To vote, users click an image on the page, which refreshes the page and passes in ?Vote=5 to the url. My php grabs this variable checks if the user can vote, and if they can the above is executed.

 

One I click the link once I dont do anything! (to make sure im not causing something else to happen) and I check my database, and indeed double the points are added instantly.

:(

Now normally this would probably be a stupid logic mistake somewhere on my part, but I want to repeat that this works perfectly on localhost, only when uploaded to the webhost it messes up. As far as I know the only difference should be various PHP settings and stuff like that which my webhost uses.

 

Any ideas on what could be causing this?  If you can figure it out in my mind you will be an official PHP genius.

Link to comment
Share on other sites

Yep I checked the values in PHP my admin and it shows that the output is correct.

 

This might help:

I tried updating it like this by dividing the amount of points given once:

UPDATE epiclink SET EpicPoints = EpicPoints + ($votes/2) WHERE ID=$whatever

 

When I did this and I inputted a vote of 3 it gave me 2 points. So it took 3/2=1 + 3/2=1.

Therefore it appears the update is being done twice, however that shouldnt be possible as I said above, I outputted an Alert, and the alert only gets called once.

 

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.

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