Jump to content

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

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.