sp@rky13 Posted November 18, 2009 Share Posted November 18, 2009 So I have this code: <?php $x = $_GET["x"];?> <?php $x1 = $_GET["x1"];?> <?php $x2 = $_GET["x2"];?> <?php $y = $_GET["y"];?> <?php $y1 = $_GET["y1"];?> <?php $y2 = $_GET["y2"];?> <?php $k = $_GET["k"];?> <?php $k1 = $_GET["k1"];?> <?php $world = $_GET["world"];?> <?php $vpt_sub = $_GET["village/player/tribe_submit"]; ?> <?php [b]if ($x=='on' AND $y=='' AND $k=='') $include = "AND x BETWEEN '$x1' AND '$x2'"; else if ($y=='on' AND $x=='' AND $k=='') $include = "AND y BETWEEN '$y1' AND '$y2'"; else if ($y=='on' AND $x=='on' AND $k=='') $include = "AND x BETWEEN '$x1' AND '$x2' AND y BETWEEN '$y1' AND '$y2'"; else if ($y=='' AND $x=='' AND $k=='') $include = ""; [u]else if ($y=='' AND $x=='' AND $k=='on') $include = $BetweenClause;[/b][/u] $yLow = floor($k1 / 10) * 100; $yHigh = $yLow + 99; $xLow = ($k1 % 10) * 100; $xHigh = $xLow + 99; $BetweenClause = "x BETWEEN $xLow AND $xHigh AND y BETWEEN $yLow AND $yHigh"; $con = mysql_connect("****","*****","*****"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("*****", $con); $result = mysql_query("SELECT village9.village, player9.name, tribe9.tag, village9.x, village9.y FROM village9 JOIN player9 ON village9.player = player9.id JOIN tribe9 ON player9.tribe = tribe9.id WHERE tribe9.tag = 'vpt_sub' $include") or die(mysql_error()); $stop=mysql_num_rows($result); $i = 1; while($row = mysql_fetch_array($result)) { echo "$i".". "."[player]".$row['name']."[/player]"." - "."[village]".$row['x']."|".$row['y']."[/village]"."<br>"; $i++; } mysql_close($con); ?> Note the "$include = $BetweenClause;" How can I do that as such as that does not work? Link to comment https://forums.phpfreaks.com/topic/182051-solved-1-variable-another/ Share on other sites More sharing options...
cags Posted November 18, 2009 Share Posted November 18, 2009 You don't set the value of $BetweenClause untill after you are assigning it to $include. So at the point your assigning it it has a NULL value. Move the block of code which generates $BetweenClause to above the if statment. Link to comment https://forums.phpfreaks.com/topic/182051-solved-1-variable-another/#findComment-960306 Share on other sites More sharing options...
sp@rky13 Posted November 18, 2009 Author Share Posted November 18, 2009 Thank you very much. Bery simple but very frustrating Link to comment https://forums.phpfreaks.com/topic/182051-solved-1-variable-another/#findComment-960312 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.