Jump to content

Quick Help - Php with MYSQL Query


summerpewp

Recommended Posts

I'm trying to do php and query some information. But it seems that i'm running into an issue.

 

Here is my code:

<?php 
	include('db.php');
	$location = mysql_query("SELECT * FROM player");
	$row = mysql_fetch_array($location);

	$newx = $row['player_loc_x']-1;
	$y = $row['player_loc_y'];
	$z = 1;
	$border = mysql_query("SELECT * FROM zones WHERE zone_id = '1' && zone_b_x = '$newx'");
	$row2 = mysql_fetch_array($border);
	$zonebx = $row2['zone_b_x'];
	$zoneby = $row2['zone_b_y'];


	if ( $newx == $zonebx && $y = $zoneby )
	{
	$_SESSION['$errormsg'] = 1;
	header("Location: ../index.php");
	}
	else {
	$_SESSION['$errormsg'] = 0;
	mysql_query("UPDATE player SET player_loc_x = '$newx'
WHERE player_id= '1'");

	header("Location: ../index.php");
	};
?>

 

What i'm trying to do is fetch some information from Mysql that meets both requirements in the IF statement. I have many that meet the first criteria but not the second. If it meets both then it proceeds, otherwise it fails. Right now, its reading it wrong .

 

For instance, in my database i have stored:

 

16, 8

16, 9

16, 10

 

it only responds to 16, 8 and doesn't recognize that 16,9 and 16,10 are still needing a check.

 

I'm not sure if i am unclear on what I'm trying to describe so please ask any more questions if need be.

 

I know the code is probably not up to standards, but i'm just learning php / mysql now so forgive the noob code.

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.