2010-06-29 18:17:55 UTC
require_once('connect.php'); //require a database connection, to include the selection of the database.
$user = trim($_GET['user']);
if(isset($user)) { //if we have a user.
$user = mysql_real_escape_string($user); //escape them for mysql interaction.
if(isset($_GET['points']) && ($_GET['points'] == 'increase' || $_GET['points'] == 'decrease')) { //if the url has 'points' set, and the = one of two things.
}
if($_GET['points'] == 'increase') { //increase the count.
$update = 'count + 1';
}
elseif($_GET['points'] == 'decrease') { //decrease the count.
$update = 'count - 1';
}
$sql = "UPDATE counter SET count = $update WHERE user_id = '$user'"; //finalize query.
mysql_query($sql); //execute query.
}
$increasePoints = 'Increase'; //increase points link set to variable.
$decreasePoints = 'Decrease'; //decrease points link set to variable.
//Call the data from the db.
$sql = "SELECT count FROM counter WHERE user_id = '$user'";
$re = mysql_query($sql);
echo mysql_errno() . ": " . mysql_error() . "\n";
$r = mysql_fetch_row($re);
$count = $r[0];
//echo the count and the variables. You can do this on the current page, or any page this code is included in.
echo 'User has ' . $count . ' points!
Do you want to ' . $increasePoints . ' or ' . $decreasePoints . '?
';
?>
However, I keep getting this message.
1054: Unknown column 'user_id' in 'where clause'
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/webvilla/public_html/test/logger/count.php on line 23
Does anybody know what I need to do in order to get this code operating?