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 Fluent udf 编写问题
  • ¥15 求合并两个字节流VB6代码
  • ¥15 Pyqt 如何正确的关掉Qthread,并且释放其中的锁?
  • ¥30 网站服务器通过node.js部署了一个项目!前端访问失败
  • ¥15 WPS访问权限不足怎么解决
  • ¥15 java幂等控制问题
  • ¥15 海湾GST-DJ-N500
  • ¥15 氧化掩蔽层与注入条件关系
  • ¥15 Django DRF 如何反序列化得到Python对象类型数据
  • ¥15 多数据源与Hystrix的冲突