Hello,

The piece of code below is basically where a member clicks on the link and then this should update that members exp_points field by the amount shown in the $points variable.

So far I have managed to get it to work so that when a member clicks the link, the code goes and enters the $points amount into their exp_points field, However, it doesnt actually ADD THE AMOUNT to the current exp_points field but instead changes the amount to the $points amount.

I have tried using a + sign to see if that would add the amount rather than set it to the $points value but this hasnt yet worked.

Does anyone know how I can get this to work and where the actual error/missing code is??

Any help is much appreciated!

<?php


ob_start();
$rank_checking = 1;
include "../global.inc.php";

// Start checking

$checking = "experience";
$limit1 = 10;
$timeLimit = "half hour";

$findUsername = fetch("SELECT * FROM members2 WHERE id = '$userid' AND game = '$game'");

$points = '300';


if ($getInfo[premium] == 1) { $limit1 = 10; $timeLimit = "15 minutes"; }
$limit = $timestamp - $limit1;

$findchecking = fetch("SELECT * FROM checking2 WHERE userid = '$userid' AND check_what = '$checking' AND timestamp > '$limit' AND game = '$game'");

if ($findchecking[id])
{
	die("$openHTML<p><center>Sorry you have collected all your experience points for today! You can come back in $timeLimit. <a href=$base_url/city_jobcentre/job_centre.php>Back</a></p>$closeHTML");
}

if (!$findchecking[id])
{
	mysql_query("DELETE FROM checking2 WHERE userid = '$userid' AND check_what = '$checking' AND game = '$game'");
	mysql_query("INSERT INTO checking2 (userid,check_what,timestamp,game) VALUES ('$userid','$checking','$timestamp','$game')");

	mysql_query("UPDATE members2 SET exp_points= + $points WHERE username = '$username' AND game = '$game'");
	
	
$error = "Your daily experience points have been added to your account!!";
}

header(error("job_centre.php", "$error"));


// End checking

?>

Sorry .. I should have defined the area of code... This is the section that im trying to sort out:

if (!$findchecking[id])
{
	mysql_query("DELETE FROM checking2 WHERE userid = '$userid' AND check_what = '$checking' AND game = '$game'");
	mysql_query("INSERT INTO checking2 (userid,check_what,timestamp,game) VALUES ('$userid','$checking','$timestamp','$game')");

	mysql_query("UPDATE members2 SET exp_points= + $points WHERE username = '$username' AND game = '$game'");

i think this is the error in your code and i have changed it to:

mysql_query("UPDATE members2 SET exp_points=exp_points+ $points WHERE username = '$username' AND game = '$game'");

i dont know exactly....

commented: Very helpful!!! +1

Thank you so much! That seems to have done the trick! :O)

Great...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.