dop83362 2012-05-21 16:49
浏览 28
已采纳

PHP:使用mysql_fetch_assoc时遇到麻烦

I am trying to return results from my database so that I can create an XML file for use in Adobe Flex, where I will then populate a Google Map. At the moment using Charles i'm getting the following error mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource

Here is the code for my function:

public function getBusiness ($item)
{
    $stmt = mysqli_prepare($this->connection,

    "SELECT * FROM businesses");

    $this->throwExceptionOnError();

    mysqli_stmt_execute($stmt);

    $this->throwExceptionOnError();

    $row = "";

    echo "<?xml version=\"1.0\" ?><map>";

    while(($row = mysql_fetch_assoc($stmt)) !== false)
    {
        echo "<business><businessid>" . $row["businessid"] . "</businessid>";
        echo "<type>" . $row["type"] . "</type>";
        echo "<name>" . $row["name"] . "</name>";
        echo "<street>" . $row["street"] . "</street>";
        echo "<city>" . $row["city"] . "</city>";
        echo "<country>" . $row["country"] . "</country>";
        echo "<postcode>" . $row["postcode"] . "</postcode>";
        echo "<latitude>" . $row["latitude"] . "</latitude>";
        echo "<longitude>" . $row["longitude"] . "</longitude>";
        echo "<phonenumber>" . $row["phonenumber"] . "</phonenumber>";
        echo "<email>" . $row["email"] . "</email>";
        echo "<website>" . $row["website"] . "</website>";
        echo "<logo>" . $row["logo"] . "</logo>";
        echo "<description>" . $row["description"] . "</description>";
        echo "<datesubmitted>" . $row["datesubmitted"] . "</datesubmitted></business>";
    }
    echo "</map>";


}

Can anybody help at all?

  • 写回答

2条回答 默认 最新

  • dtah63820 2012-05-21 17:32
    关注

    You should use fetch_array() instead of mysql_fetch_assoc()

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用