Page 1 of 1

[SOLVED] $_SESSION Problem!!!

Posted: Sat Mar 13, 2004 10:54 am
by Joe
Recently I have been trying to create a points system for my site where users can gain points to their account by completing challenges. I am trying to update their current score by using a SESSION which holds their username. When I try to add 25 points to the account I get an error. The code go's like:

if ($app1 == "pass")
$link = mysql_connect("???", "???", "???");
mysql_select_db("???") or die("couldnt connect" . mysql_error());
$sql = "SELECT points FROM members WHERE SesID = $_SESSION['username']";
$result = mysql_query($sql) or die(mysql_error());

if (mysql_num_rows($result))
{
$row = mysql_fetch_assoc($result);
mysql_query("INSERT INTO members ('points') VALUES(points + 25"));
mysql_close($link);
}

Can anyone please help me with this problem??

Regards



Joe 8)

Posted: Sat Mar 13, 2004 12:05 pm
by infolock
this should work :

$sql = "SELECT points FROM members WHERE SesID = '".$_SESSION['username']."'";
$result = mysql_query($sql) or die(mysql_error());

$row = mysql_result($result);
$points = $row + 25;

mysql_query("INSERT INTO members (points) VALUES('".$points."')");

unless your points field was declared as a varchar field. basically, you just wasn't using the quotes correctly. i added a little more to it, but shoudl work...

Posted: Wed Apr 07, 2004 1:56 am
by infolock
marking this thread at solved.