Jump to content

[SOLVED] Simple script playing up...


mattal999

Recommended Posts

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
Link to comment
https://forums.phpfreaks.com/topic/70673-solved-simple-script-playing-up/
Share on other sites

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 :P

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.