开发者

php/mysql query problem

Can anybody tell me what's wrong with the following code ---

for($i=0; $i<count($strnamearray); $i++){
echo $strnamearray[$i]."<br />";

$cordcquery = "SELECT `lat` , `lng` FROM `traffic` WHERE `strname` = '{$strnamearray[$i]}' LIMIT 0 , 30;";
$cordresult = mysql_query($cordcquery);

if (!$cordresult) 
 {
  die('Invalid strncquery:开发者_如何学C ' . mysql_error());
 }

while($cordrow = @mysql_fetch_assoc($cordresult)){
    echo $cordrow['lng'].",".$cordrow['lat'];
    echo "<br />";
}
}

Here $strnamearray[$i] is an array which contains some name. there is no error showed after executing this php code. But the problem is i am not getting my desired output...


This is a shot in the dark here with out some more information but two things.

  1. echo $cordcquery just to make sure the sql looks right and you can execute it directly in MYSQL. From what I can tell it should but without knowing whats in the variables I'm not sure.

  2. Instead of LIMIT 0, 30 use just LIMIT 30. Should be the same thing but I have seen some funkiness depending on what versions of php and mysql you are using with passing LIMIT offset, row count. From what I can remember it would take the offset and not parse the row count and therefore would not return any information.

Let me know if this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜