Jump to content

What did i do wrong in this?


sp@rky13

Recommended Posts

Ok so I've been messing with the following code but don't know what i've done wrong. The error is definitely here.

 

$result4 = mysql_query("SELECT * FROM villages_en28 WHERE player = '".$id2"' AND x BETWEEN 400 AND 450 AND y BETWEEN 400 and 450");

 

What it should do is take all the values of id2 and look them up in the table village and then only keep the ones that have an x value between 400 and 450 as well as a y value between 400 and 450.

 

I would then echo those results like this:

 

while($row4 = mysql_fetch_array($result4))
{
echo $row4['x']."|".$row4['y']."</br>"; 
}

Link to comment
https://forums.phpfreaks.com/topic/170068-what-did-i-do-wrong-in-this/
Share on other sites

Are you getting an error or just no results?

If the latter (no results) then I suggest you look at what data you are expecting.

 

Run the following with a static "id" value directly in MySQL to see what results you are getting.

SELECT * FROM villages_en28 WHERE player = '< PLACE ID HERE >' AND x BETWEEN 400 AND 450 AND y BETWEEN 400 and 450

 

If you get no results examine why the data doesn't match up. I suspect because there is no player with x and y between those values.

Also consider bracketing your SQL for better clarity, e.g. ... AND (x BETWEEN 400 AND 500) AND ...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.