Find the Error!! Yay!!
Posted: Sat Feb 05, 2005 11:19 am
Hey guys!
This code is for users to purchase a horse on my virtual reality horse game. The error I'm getting is an unexpected '=' on line 69. Anyone want to figure this out?
This code is for users to purchase a horse on my virtual reality horse game. The error I'm getting is an unexpected '=' on line 69. Anyone want to figure this out?
Code: Select all
<?php
// For register_global on PHP settings
$member = $_COOKIEї'member'];
session_start(); // you must put this to read session variables
if (empty($member) || !isset($member)) // fail to read the browser cookie
{
// Try to read session
if (empty($_SESSIONї'member']) || !isset($_SESSIONї'member']))
{
header("Location: log.php"); // redirect user to login
exit;
}
else
{
$member = $_SESSIONї'member'];
}
}
// MySQL Connection Variables
// Fill in your values for the next 4 lines
$hostname='localhost';
$user='*******'; //'user name for MySQL database';
$pass='*****'; //'Password for database';
$dbase='*************'; //'database name';
$connection = mysql_connect("$hostname" , "$user" , "$pass") or die ("Can't connect to MySQL");
$db = mysql_select_db($dbase , $connection) or die ("Can't select database.");
// User has login but you should check his account validity again
$qChk = "select id from members where uname='$member' and status='Y' ";
$rsChk = mysql_query($qChk);
if (mysql_num_rows($rsChk) != '1')
{
header("Location: log.php");
exit;
}
?><?php include('top.php'); ?>Purchase Horse<?php include('next2.php'); ?>Purchase Horse<?php include('middle.php'); ?>
<?php
//Script © Kate MacDougall
//It is for purchasing horses on a SIM game called Equinique
//She worked her butt off to make, steal it and she'll not be very pleased
//Thanks and have a great day :-p
// MySQL Connection Variables
// Fill in your values for the next 4 lines
$hostname='localhost';
$user='********'; //'user name for MySQL database';
$pass='******'; //'Password for database';
$dbase='********'; //'database name';
$connection = mysql_connect("$hostname" , "$user" , "$pass") or die ("Can't connect to MySQL");
$db = mysql_select_db($dbase , $connection) or die ("Can't select database.");
//The following are the variables sent from the horse.php page where the user clicked a button, agreeing to purchase the horse. They're hidden, soooo....
$price = $_POSTї'price'];
$name = $_POSTї'name'];
//This is the thing to see how many horses a user has
$q = mysql_query("SELECT * FROM horses WHERE owner='$uname'");
$g = mysql_num_rows($q);
//The following gets the amount of money a user has.
$money = ("SELECT * FROM members WHERE uname='$uname' AND money='$money'");
$cmon = mysql_query($money);
//Next check how many horses a user has
if($g>=20){
die("You have too many horses, and you cannot own more.");
}
//Purchase the horse and set the owner to the name, meaning that the horse was previously owned, not a horse created by the game, which would be "Unowned".
if($g<=20 && $money>=$price && owner='$owner')
{
//Subtract the price from the member....
$updateone = ("UPDATE * TABLE members WHERE uname='$member' SET $money - $price");
$uptwo = mysql_query($updateone);
//Give the old owner the money
//When they bought the horse it set fowner as being their name
//Fowner will change below
$pay = ("UPDATE * TABLE horses SET $fowner + $price");
$p = mysql_query($pay);
//Set fowner to member
$updatetwo = ("UPDATE * TABLE horses SET owner='$member' and fowner='$member'");
$upthree = mysql_query($updatetwo);
//Tell 'em the good news...
echo "You've purchased this horse!";
}
//This is the script for horses who are Unowned, as in created by the game. This is different because Unowned isn't actually an account, so we cannot give it money.
if($g<=20 && $money>=$price && owner='Unowned')
{
//Subtract the money...
$updateone = ("UPDATE * TABLE members WHERE uname='$member' SET $money - $price");
$uptwo = mysql_query($updateone);
//Make it fowner
$updatetwo = ("UPDATE * TABLE horses SET owner='$member' and fowner='$member'");
$upthree = mysql_query($updatetwo);
//Tell them they've purchased.
echo "You've purchased this horse!";
}
//This is incase they don't have enough money to purchase the horse.
if($g<=20 && $money<=$price)
{
echo "You don't have enough to purchase this horse.";
}
//I wasn't totally sure what to put here, so....
else
{
echo "Whoops, contact technical support, somethings gone wrong!";
}
?>