mattd8752
01-21-2007, 01:03 PM
I'm getting:
Parse error: syntax error, unexpected '{' in /home/mattd/public_html/racing/purchase.php on line 43
on:
<?php
//PHP DB connect here
session_start();
mysql_connect("localhost", "mattd_rpg", "didyoureallyexpectmetogiveyouthis") or die("There was an error connecting to the mysql server.");
mysql_select_db("mattd_rpg");
$username=$_SESSION['username'];
$password=$_SESSION['password'];
$result=mysql_query("SELECT * FROM accounts WHERE username='$username' AND password='$password'");
if(mysql_num_rows($result) == 0){
die("Sorry, you are not logged in, please login again to continue playing. If you just signed in your username and/or password may be incorrect");
}else{
$query="select * from accounts";
$rt=mysql_query($query);
echo mysql_error();
while($nt=mysql_fetch_array($rt)){
if($nt[username] == $username){
echo $nt['username'].' '.$nt['money'].' '.$nt['email'].'<br>';
}
}
}
$cash = $nt[money];
//LOGIN CHECK MUST BE ADDED
$query="SELECT * FROM cars";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b><center>Cars:</center></b><br><br>";
$i=0;
while ($i < $num) {
$id=mysql_result($result,$i,"id");
$name=mysql_result($result,$i,"name");
$hp=mysql_result($result,$i,"hp");
$price=mysql_result($result,$i,"price");
$owner==mysql_result($result,$i,"owner");
if(!isset($owner){
if($cash > $price){
echo "ID: <a href=\"purchase.php?buy=" . $id . "\">" . $id . "</a><br>Name:" . $name . "<br>HP:" . $hp . "<br>Sale Price:" . $price . "<br><br>";
}else{
echo "ID:" . $id . "<br>Name:" . $name . "<br>HP:" . $hp . "<br>Sale Price:" . $price . " (you can\'t afford this car)<br><br>";
}
}else{
echo "<br>This car is sold.<br>";//Testing purposes only
}
$i++;
}
?>
I don't quite get what the problem is, I have redone the and tried to look at the else & if statements many times, it just doesn't want to work. Any suggestions or fixes?
Parse error: syntax error, unexpected '{' in /home/mattd/public_html/racing/purchase.php on line 43
on:
<?php
//PHP DB connect here
session_start();
mysql_connect("localhost", "mattd_rpg", "didyoureallyexpectmetogiveyouthis") or die("There was an error connecting to the mysql server.");
mysql_select_db("mattd_rpg");
$username=$_SESSION['username'];
$password=$_SESSION['password'];
$result=mysql_query("SELECT * FROM accounts WHERE username='$username' AND password='$password'");
if(mysql_num_rows($result) == 0){
die("Sorry, you are not logged in, please login again to continue playing. If you just signed in your username and/or password may be incorrect");
}else{
$query="select * from accounts";
$rt=mysql_query($query);
echo mysql_error();
while($nt=mysql_fetch_array($rt)){
if($nt[username] == $username){
echo $nt['username'].' '.$nt['money'].' '.$nt['email'].'<br>';
}
}
}
$cash = $nt[money];
//LOGIN CHECK MUST BE ADDED
$query="SELECT * FROM cars";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b><center>Cars:</center></b><br><br>";
$i=0;
while ($i < $num) {
$id=mysql_result($result,$i,"id");
$name=mysql_result($result,$i,"name");
$hp=mysql_result($result,$i,"hp");
$price=mysql_result($result,$i,"price");
$owner==mysql_result($result,$i,"owner");
if(!isset($owner){
if($cash > $price){
echo "ID: <a href=\"purchase.php?buy=" . $id . "\">" . $id . "</a><br>Name:" . $name . "<br>HP:" . $hp . "<br>Sale Price:" . $price . "<br><br>";
}else{
echo "ID:" . $id . "<br>Name:" . $name . "<br>HP:" . $hp . "<br>Sale Price:" . $price . " (you can\'t afford this car)<br><br>";
}
}else{
echo "<br>This car is sold.<br>";//Testing purposes only
}
$i++;
}
?>
I don't quite get what the problem is, I have redone the and tried to look at the else & if statements many times, it just doesn't want to work. Any suggestions or fixes?