Q695 Posted September 25, 2012 Share Posted September 25, 2012 For some reason X, and Y are being rewritten (only option 1 is showing up but the other stuff is visible) when they're intrtnal to the function (subtracting 1). <?php function mapgen($x, $y){ global $con, $cx, $cy, $cz, $m_q, $m_w, $m_e, $m_a, $m_s, $m_d, $m_z, $m_x, $m_c; $mx=$cx+$x; $my=$cy+$y; echo $x.",". $y; $sql_m= "select * from map WHERE x=$mx AND y=$my AND z=$cz"; $result = mysql_query($sql_m, $con) or die ("can not generate result " . mysql_error()); $row_m = mysql_fetch_assoc($result); //print_r($row_m); //echo $mx . "," . $my; if ($row_m) { echo "<img src='images/" . $row_m['img'] . "' alt='terain' height='20' width='20' />"; if ($x='-1' && $y='1') {$m_q=1;} else if($x='0' && $y='1') {$m_w=1;} else if($x='1' && $y='1') {$m_e=1;} else if($x='-1' && $y='0') {$m_a=1;} else if($x='0' && $y='0') {$m_s=1;} else if($x='1' && $y='0') {$m_d=1;} else if($x='-1' && $y='-1') {$m_z=1;} else if($x='0' && $y='-1') {$m_x=1;} else if($x='1' && $y='-1') {$m_c=1;} else { echo"error"; } } else { echo "<img src='images/clear.gif' height='20' width='20' alt='null'>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/268788-debugging-help-movement-generator/ Share on other sites More sharing options...
Jessica Posted September 25, 2012 Share Posted September 25, 2012 For one thing, you need to use some variable names that MEAN something. Next, actually explain what you are trying to do, what's not working, what you expect, what you get. Link to comment https://forums.phpfreaks.com/topic/268788-debugging-help-movement-generator/#findComment-1380874 Share on other sites More sharing options...
kicken Posted September 25, 2012 Share Posted September 25, 2012 On 9/25/2012 at 5:36 PM, Q695 said: if ($x='-1' && $y='1') = is an assignment, meaning you are assigning '-1' to $x and '1' to $y. If you want to test the value of $x against '-1' to see if they are equal, you need to use == (two equal signs) Link to comment https://forums.phpfreaks.com/topic/268788-debugging-help-movement-generator/#findComment-1380878 Share on other sites More sharing options...
Q695 Posted September 26, 2012 Author Share Posted September 26, 2012 X, and Y are geometry figures the == solved it for the most part, just need to figure out the last bug on my own Link to comment https://forums.phpfreaks.com/topic/268788-debugging-help-movement-generator/#findComment-1380954 Share on other sites More sharing options...
Jessica Posted September 26, 2012 Share Posted September 26, 2012 if you think in a month you'll remember what m_s, m_e, m_c, m_d, m_a and m_z are, then fine. x and y are obviously axes. The rest of it doesn't make any damn sense. Link to comment https://forums.phpfreaks.com/topic/268788-debugging-help-movement-generator/#findComment-1381041 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.