mattal999 Posted September 25, 2007 Share Posted September 25, 2007 Hi, i made this script and it comes up with an error: <?php session_start(); include 'connect.php'; $name = $_GET['car']; $price = $_GET['price']; $engine = $_GET['engine']; $username = $_SESSION['username']; $usercreds1="SELECT * from dragusers WHERE username='$username'"; $usercreds2=mysql_query($usercreds1) or die("Could not select user."); $usercreds3=mysql_fetch_array($usercreds2) $gold = $usercreds3[credits]; if($gold>=$price) { $updateplayerstats="Update dragusers set credits=credits-'$gold', engine='$engine', car='$name' where username='$username'"; mysql_query($updateplayerstats) or die("Could not update players car"); print "You brought the $name for $price"; } else { print "You have insufficient credits"; } ?> and it comes up with the error: Parse error: syntax error, unexpected T_VARIABLE in /home/users/uks51756/html/games4uonline.com/drag/buycar.php on line 17 Quote Link to comment https://forums.phpfreaks.com/topic/70673-solved-simple-script-playing-up/ Share on other sites More sharing options...
Orio Posted September 25, 2007 Share Posted September 25, 2007 You are missing a semicolon in line 13: $usercreds3=mysql_fetch_array($usercreds2); Orio. Quote Link to comment https://forums.phpfreaks.com/topic/70673-solved-simple-script-playing-up/#findComment-355203 Share on other sites More sharing options...
envexlabs Posted September 25, 2007 Share Posted September 25, 2007 Also, just a little tip: $updateplayerstats="Update dragusers set credits=credits-'$gold', engine='$engine', car='$name' where username='$username'"; mysql_query($updateplayerstats) or die("Could not update players car"); is the same as: $updateplayerstats=mysql_query("Update dragusers set credits=credits-'$gold', engine='$engine', car='$name' where username='$username'") or die("Could not update players car");; just saves a line of code Quote Link to comment https://forums.phpfreaks.com/topic/70673-solved-simple-script-playing-up/#findComment-355205 Share on other sites More sharing options...
mattal999 Posted September 25, 2007 Author Share Posted September 25, 2007 Hey orio, long time no see, remember RpgNOW? Cheers mate, worked a charm. It's my new project, Drag Racer. Will post beta testing when complete! Cheers again mate. EDIT: and thanks envexlabs! that will be handy I always use databases everywhere lol. Quote Link to comment https://forums.phpfreaks.com/topic/70673-solved-simple-script-playing-up/#findComment-355206 Share on other sites More sharing options...
mattal999 Posted September 25, 2007 Author Share Posted September 25, 2007 One more problem: when i buy a car worth 55000 credits and i have 55000+ i have 0 credits afterwards.... Fixed Quote Link to comment https://forums.phpfreaks.com/topic/70673-solved-simple-script-playing-up/#findComment-355213 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.