:bemused:
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.