easy question - need some help

cheva

Power Member
Joined
Aug 22, 2009
Messages
557
Reaction score
761
whats wrong with this code :S

Code:
mysql_connect($mysql_where, $mysql_username, $mysql_password);
mysql_select_db($mysql_database);

/*
 * test postback
 */
include("includes.php");
$new = $_REQUEST['new'];
$uid = $_REQUEST['uid'];
$total = $_REQUEST['total'];
$oid = $_REQUEST['oid'];


//$query_getuserid = mysql_query("SELECT id from members WHERE username= '".$uid."'") or die(mysql_error());
//foreach(mysql_fetch_array($query_getuserid) as $userid);


mysql_query("UPDATE members SET points=points+".$new." WHERE username='".$uid."'");
mysql_close();
echo "Success: ".$uid." earned ".$new." points\n";

when i test postback for a given uid, the points get updated, but they keep adding after every couple of minutes.
Its supposed to update the points once, and then close the statement.

im no php guru so sum insight wud be appreciated
 
Maybe I didn't understand your problem, but if you run that code several times, the points will always update each time you run it.
 
First of all add
PHP:
if(! ) { echo mysql_error(); }
for all of your mysql queries.

Second, here
PHP:
mysql_query("UPDATE members SET points=points+".$new." WHERE username='".$uid."'");
- try using the same apostrophe encapsulation as the userid variable.

Third, is this file included/referenced by other executing scripts in your program?

Fourth, is the global
PHP:
$_REQUEST
really necessary? Is it not a POST/GET?

I don't know the conditions of the script so I hope you can figure out. This error shouldnt be occurring as things look normal.

On second notice, comparing to my own script, I don't think you should have '".$var."' as an encapsulation of a bare variable in a mysql query. Remove the double quotes and check again.
 
Last edited:
Back
Top