这里似乎有错误,但我没有看到它.查询正在工作,但回声不工作


There seems to be a error here, but I don't see it. The query is working but the echos are not!

这个查询工作得很好,但是在定义中似乎有一个错误,因为没有产生回声。

<?php
            $dbname = 'pdartist2';
            $table = 'artowrk';
            // query
            $result = mysql_query("select AID, ThumbFilePath, Title, DisplayOrder from artwork where SCID = $SCID") or die(mysql_error());
            while($row = mysql_fetch_row($result)){
                $AID = $row['AID'];
                $ThumbFilePath = $row['ThumbFilePath'];
                $Title = $row['Title'];
                $DisplayOrder = $row['DisplayOrder'];
                echo "$AID";
                echo "$ThumbFilePath";
                echo "$Title";
                echo "$DisplayOrder";
            }
            mysql_free_result($result);
        ?>

mysql_fetch_row不返回关联数组,返回的数组是一个数字索引数组。所以你必须使用数值索引来访问它就像下面的

echo $row[0];
echo $row[1];

如果您希望数组是一个关联数组,您可以尝试mysql_fetch_arraymysql_fetch_assoc

while($row = mysql_fetch_assoc($result)){

使用mysql_fetch_arraymysql_fetch_assoc

,而不是echo使用var_dump(),它将确保你得到输出,即使是布尔值false,被echo或print_r忽略