I'm trying to create a level system, where users gain exp through certain actions and when they have enough, they level up!
I've created this levelsystem.php file and included it in header.php so its on every page but it doesn't seem to be working.

```
 <?php
$res = mysql_query("SELECT `level`, `exppoints` FROM `users` WHERE `id` = '".$_SESSION['uid']."'");
$data = mysql_fetch_assoc($res);

$level = $data['level'];
$exp = $data['exppoints'];
$expneed = 100;
$levelup = $level * $expneed;

if($exp == $levelup) {
$res2 = mysql_query("UPDATE `users` SET `level` = level+1, `exppoints` = exppoints-'".$levelup."' WHERE `id` = '"$_SESSION['uid']."'");
}
?>

```

It shows an error for an unexpected variable which I'm assuming is the $levelup in the query, but can't see a way around it.