关于浏览器报错问题PHP Warning: preg_match() expects.

WBOY
Release: 2016-06-23 13:49:31
Original
2134 people have browsed it

PHP Warning:  preg_match() expects parameter 2 to be string, object given in C:\inetpub\wwwroot\hp\4.php on line 80


if(!$this -> result || !eregi("^Resource", $this -> result))   {        return $this->output("没有数据,请先执行SQL的'select'语句!");      }
Copy after login

if(!$this -> result || !preg_match("/^Resource/i", $this -> result))  {        return $this->output("没有数据,请先执行SQL的'select'语句!");      }
Copy after login
由于PHP从5.2以下升级到5.6了,原来用的mysql语句全改为mysqli语句了 ,结果不能读取数据。按照百度提示换了语句可惜还不能用报错了,现在这个怎么解决????


回复讨论(解决方案)

$this->result 是资源吧?
判断是否为资源应用 is_resource 函数
if(! $this->result || ! is_resource($this->result))

$this->result 是资源吧?
判断是否为资源应用 is_resource 函数
if(! $this->result || ! is_resource($this->result))



$this -> result = @mysqli_query($this -> conn,$this -> sql);
Copy after login
这句是这样的

回复 #1,我换了你的 is_resource 函数 解决了报错问题 ,可惜还是读取不了数据库

你把$this->result var_dump一下看是什么东西

回复 #4 var_dump($this -> result)这样么? 加在哪里

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template