Jump to content

[SOLVED] coders block (and issue)


Q695

Recommended Posts

There is no data, so shouldn't it be saying that you don't have anything in a way instead of death?

output:SELECT * FROM `map` WHERE `location_x`='-3' AND `location_y`='3' AND `level`='1';

<?php
function loc_img ($mx, $my, $location_x, $location_y){
global $location_x, $location_y, $level;
	$location2_x=$location_x+$mx;
	$location2_y=$location_y+$my;
	$sql="SELECT * FROM `map` WHERE `location_x`='$location2_x' AND `location_y`='$location2_y' AND `level`='$level';";
	$result=@mysql_query($sql,$con) or die(death($sql));
	$m_row=mysql_fetch_array($result);
}
?>

Link to comment
https://forums.phpfreaks.com/topic/151486-solved-coders-block-and-issue/
Share on other sites

A query that executes but has zero rows in the result set is a successful query. Only queries that fail to execute return a FALSE value that would trigger an or die() statement.

 

To test if there were any rows returned you would need to use mysql_num_rows() or put the $m_row=mysql_fetch_array($result) inside of a conditional statement -

 

if($m_row=mysql_fetch_array($result)){
    // fetch worked, process $m_row here
} else {
   // no row to fetch
   echo "zero matching rows<br />";
}

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.