警告:mysql_fetch_array() 期望参数 1 是资源,数组在 [英] Warning: mysql_fetch_array() expects parameter 1 to be resource, array given in

查看:41
本文介绍了警告:mysql_fetch_array() 期望参数 1 是资源,数组在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么会出现上述错误?

Why does it give above mentioned error?

代码如下:

$replace =  str_replace(", "," | ", $result2);
while ($line = mysql_fetch_array($result2, MYSQL_BOTH)){ 
    mysql_query("INSERT INTO listings

推荐答案

您正在使用 资源上的字符串函数.PHP 是弱类型的,因此它可以让您在短期内摆脱它(没有运行时错误),但它是通过先将资源转换为字符串,然后进行替换来完成的.所以它不再是一种资源.

You are using a string function on a resource. PHP is weakly typed so it lets you get away with it in the short term (no runtime error), but it is done by converting the resource to string first, then doing the substitutuin. So it is not a resource anymore.

这篇关于警告:mysql_fetch_array() 期望参数 1 是资源,数组在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆