Okay, so I have two pages. The first is included in the second.
Part of the first calls for two variables ($playerx and $playery). It checks to see if they have been posted, and if not, goes on to check a database. If all this fails, it assigns a standard value (2).
It then goes on to create various arrays to handle information regarding that information.
The second page displays various information from a database. However, par of it uses a query that needs information from an array created on the first page. But the value isn't setting properly, as I then get a syntax error.
Warning: mysql_query() [http://www.mysql.com/doc]: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND y = AND username != 'Test3'' at line 1 in /var/www/virtual/staggy11.byethost3.com/htdocs/maptest.php on line 13
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND y = AND username != 'Test3'' at line 1
The query is
$result = mysql_query("SELECT `username` FROM `players` WHERE `x` = ". $object[5]->x ." AND `y` = ". $object[5]->y ." AND username != '$name'") or die(mysql_error());
The first page code (relevant stuff) is
if (($_POST[x])&&($_POST[y]))
{
$playerx = $_POST[x];
$playery = $_POST[y];
}
else if ((!$_POST[x])||(!$_POST[y])){
$query = mysql_query("SELECT * FROM players WHERE `username`='".$_SESSION['username']."'");
if (($query)&&($query->x > 0)&&($query->y > 0)){
$playerx = $query->x;
$playery = $query->y;
}
else if (!$query)
{
$playerx = 2;
$playery = 2;
}
}
echo "X is ".$playerx.".";
echo "Y is ".$playery.".";
$x = array (
"1" => $playerx-1,
"2" => $playerx,
"3" => $playerx+1,
"4" => $playerx-1,
"5" => $playerx,
"6" => $playerx+1,
"7" => $playerx-1,
"8" => $playerx,
"9" => $playerx+1,
);
Can anyone work out where I am going wrong? I think that it may be that the array isn't setting properly, but thats just an uneducated guess.
I'm really sorry to ask this, but please, can anyone help?