Log in

View Full Version : lets play, find the error!



Demonicman
03-02-2007, 11:45 PM
<?php
//no Mysql info for you :)


$username = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{
function mySum($numX, $numY){
$total = $numX + $numY;
return $total;
}
$newpoints = $info['points'];
echo "Before now, your points were = ". $newpoints ."<br />";
// Store the result of mySum in $newpoints
$newpoints = mySum($info['points'], 1);
echo "After now, your points are = " . $newpoints ."<br />";

mysql_query("UPDATE users SET points='$newpoints' WHERE points='$info[\'points\']' ")
or die(mysql_error());
}
?>
<a href="account.php">Continue?</a>

Now i bet your wondering why i posted this here... well...


Parse error: parse error, unexpected T_BAD_CHARACTER, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\account\addpoints.php on line 21

Twey
03-02-2007, 11:50 PM
<?php
// You might want to leave the actual lines in so that the line number makes sense.
// Replace the details with Xs.

$username = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
$check = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
while($info = mysql_fetch_array( $check )) {
$newpoints = $info['points'];
echo "Before now, your points were = " . ($newpoints++) . "<br>";
echo "After now, your points are = " . $newpoints ."<br>";

mysql_query("UPDATE users SET points='$newpoints' WHERE points='{$info['points']}'") or die(mysql_error());
}
?>
<a href="account.php">Continue?</a>

Demonicman
03-03-2007, 12:03 AM
//as always
//thanks again twey :)
//and ill remember to put the comments on :P
//for next time