无法在MySQL结果索引13上跳转到第0行

时间:2010-04-25 16:20:36

标签: php mysql

标题错误的原因是什么?我在Mysql Front上测试了mysql查询并没有问题。我的脚本如下。谢谢。

$fbFoodPerma = $fbSiteID."-".$fbFoodPerma;  
    $sql = mysql_query("  
        SELECT fbFoodPerma   
        FROM fbFoods   
        WHERE fbFoodPerma   
        LIKE '$fbFoodPerma'") or die(mysql_error());  
    $isStored = mysql_result($sql,0,"fbFoodPerma");  
    while ($isStored == "$fbFoodPerma") {  
    $fbFoodPerma = $fbFoodPerma."-";  
    $sql = mysql_query("  
        SELECT fbFoodPerma   
        FROM fbFoods   
        WHERE fbFoodPerma   
        LIKE '$fbFoodPerma'") or die(mysql_error());  
        $isStored = mysql_result($sql,0,"fbFoodPerma");  
        }  

1 个答案:

答案 0 :(得分:4)

嗯,试试看它是否正在拾取任何数据:

$sql="SELECT * FROM fbFoods";
$query = mysql_query($sql) or die ("Could not match data because ".mysql_error());
$num_rows = mysql_num_rows($query);

if ($num_rows > 0) {
    echo "rows found";
    } else {
    echo "none found";
}

还要确保$fbFoodPerma实际包含某些内容 - 尝试在查询结束时回显它。

echo $fbFoodPerma;