Since we all love find the error...
Posted: Tue Feb 08, 2005 6:32 pm
Again! I know! I suck at doing this game myself.
First of all, I'm not using Jade's login script cause mine works and I don't feel like re-doing my files. (It wouldn't work before.)
The following code gives me this error.
Anyone got any ideas?
First of all, I'm not using Jade's login script cause mine works and I don't feel like re-doing my files. (It wouldn't work before.)
The following code gives me this error.
CodeYou have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE uname='1'' at line 1
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: login.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 name='$member' and status='Y' ";
$rsChk = mysql_query($qChk);
if (mysql_num_rows($rsChk) != '1')
{
header("Location: login.php");
exit;
}
// Rest of your welcome page content here
?><?php
include('top.php');
echo "Purchase Horse";
include('next2.php');
echo "Purchase Horse";
include('middle.php');
//Script done by Kate MacDougall and Jade Krafsig of design1online.com
//
// 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.");
//variables from horse.php
$price = $_POSTї'price'];
$name = $_POSTї'name'];
//Question for you, where is $uname coming from???
//That could give you a problem
//if you make your variable names better then its easier
//to figure out what is going on
//This is the thing to see how many horses a user has
$query = mysql_query("SELECT * FROM horses WHERE owner='$member'") or die (mysql_error());
$numhorses = mysql_num_rows($query);
$getmoney = "select `money` from members where uname='$member' ";
$smoney = mysql_query($getmoney);
$row = mysql_fetch_array($smoney);
$money = $rowї'money']
?>
<?php
if($numhorses >=20)
{
echo("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($numhorses < 20 && ($money - $price) > 0 && $owner !='Unowned')
//{
//update members money
mysql_query("UPDATE members SET money=$money-$price WHERE uname='$member'") or die (mysql_error());
//Give the old owner the money
//You need the name of the old owner here...
//where are you getting that above??
//you need to get oldowner and set it as $oldowner
mysql_query("UPDATE members SET money=money+$price WHERE uname='$oldowner") or die (mysql_error());
//Set fowner to member
mysql_query ("UPDATE horses SET owner='$member' and fowner='$member'") or die (mysql_error());
//end horse already has an owner
//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($numhorses < 20 && ($money - $price) > 0 && $owner == 'Unowned')
{
//Subtract the money...
mysql_query ("UPDATE members SET money=money-$price WHERE uname='$member'") or die (mysql_error());
//Make it fowner
mysql_query("UPDATE horses SET owner='$member' and fowner='$member'") or die (mysql_error());
//Tell them they've purchased.
echo "You've purchased this horse!";
}
//This is incase they don't have enough money to purchase the horse.
else if (($money - $price) < 0)
{
echo "You don't have enough to purchase this horse.";
}
include('end.php'); ?>
?>