简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM