<?php
include "globals.php";
$_GET['to'] = abs((int) $_GET['to']);
if(!$_GET['to'])
{
print "Welcome to the Monorail Station.
Where would you like to travel today?
";
$q=$db->query("SELECT * FROM cities WHERE cityid != {$ir['location']} AND cityminlevel <= {$ir['level']}");
print "<table width=75% cellspacing=1 class='table'><tr style='background:gray'><th>Name</th><th>Description</th><th>Min
Level</th><th>Cost</th><th></th></tr>";
while($r=$db->fetch_row($q))
{
print "<tr><td>{$r['cityname']}</td><td>{$r['citydesc']}</td><td>{$r['cityminlevel']}</td><td>\${$r['citycost']}</td><td><a href='monorail.php?to={$r
['cityid']}'>Go</a></td></tr>";
}
print "</table>";
}
else
{
if($ir['money'] < $r['citycost'])
{
print "You don't have enough money. You need {$r['citycost']} to travel to {$r['cityname']}";
}
else if( ((int) $_GET['to']) != $_GET['to'])
{
print "Invalid city ID";
}
else
{
$q=$db->query("SELECT * FROM cities WHERE cityid = {$_GET['to']} AND cityminlevel <= {$ir['level']}");
if(!$db->num_rows($q))
{
print "Error, this city either does not exist or you cannot go there.";
}
else
{
$db->query("UPDATE users SET money=money-{$r['citycost']},location={$_GET['to']} WHERE userid=$userid");
$r=$db->fetch_row($q);
print "Congratulations, you paid \${$r['citycost']} and travelled to {$r['cityname']} on the monorail!";
}
}
}
$h->endpage();
?>
[mysql]ALTER TABLE `cities` ADD `citycost` INT( 11 ) NOT NULL AFTER `cityid` ;[/mysql]
This is my script but I get this...
QUERY ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'location=2 WHERE userid=1' at line 1
Query was UPDATE users SET money=money-,location=2 WHERE userid=1
Any ideas?