PHP Fatal error: Call to a member function query() on a non-object in F 代码如下

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP Fatal error: Call to a member function query() on a non-object in F 代码如下相关的知识,希望对你有一定的参考价值。

<?php
$db=mssql_connect("*****","*****","******") or die ("can not Connect to Database");
mssql_select_db("XXX");
echo "Success....";
$rows = $db->query('SELECT * FROM XXXX');
while($row = $rows->fetch_assoc())
echo "<td width=\"300\">".$row['stcd']."</td>  ";
echo "<td>".$row['endtm']."</td>";
echo "<td>".$row['value']."</td>";

exit;
?>

PHP Fatal error: Call to a member function query() 调用未正确生成对象 也就是说,
$db没定义。

造成的可能是因为你引入的文件没正确引入 或者是你压根就没生成$db对象
参考技术A 你的$db是未定义的,所以query这个方法也不存在

$rows = $db->query('SELECT * FROM XXXX');

这里应该这样写,
$rows = mysql_query('SELECT * FROM XXXX');

望采纳!~本回答被提问者采纳
参考技术B $db=mssql_connect 此语句之后 $db不是对象,不能用$db->query,只能用mssql_query
看看你的教材,不要把过程部分和对象混淆了,要用对象需要使用 $dn = New这样的格式。
参考技术C mssql_connect连接成功之后,它是返回一个连接标识符,是resource类型的,不是一个object。
所以,应该是$rows = mssql_query('select * from xxx');
或者$rows = mssql_query('select * from xxx',$db);//因为第二个参数可以省略。
参考技术D mssql_query

Fatal error: Call to undefined function oci_connect()

 

http://stackoverflow.com/questions/22478387/call-to-undefined-function-oci-connect

  1. Whenever you connecting Oracle Database , try to use 32 Bit oracle client libraries, Since XAMP PHP is compiled with 32 Bit(Though you have 64 Bit windows Machine)
  2. Download Oracle Client from Download From here

  3. Paste it in C:\instantclient_12_1

  4. Then Set the path to above in System Environment Variable
  5. Then Go to C:\xampp\php\php.ini and uncomment extension=php_oci8_12c.dll
  6. Then Restart the XAMP and it should work without any Issue.

以上是关于PHP Fatal error: Call to a member function query() on a non-object in F 代码如下的主要内容,如果未能解决你的问题,请参考以下文章

Fatal error: Call to undefined function fnmatch() 解决

PHP-问题处理Fatal error: Uncaught Error: Call to undefined function simplexml_load_file()

Fatal error: Call to undefined function pasterTempletDiy()

Fatal error: Call to undefined function curl_init()问题

Fatal error: Call to undefined function curl_init()解决办法

linux下PHP环境中Fatal error: Call to undefined function mysql_connect() 出错