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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.