php数据库操作Call to a member function Execute() on a non-obje报错
class sqlitedb {
//打开sqlite数据库
function conn($dbname) {
$conn = null;
$path ="/etc/ypm/system.cfg";
if(file_exists($path)){
$dbname = str_replace('../', '', $dbname);
$dbname = str_replace('./', '', $dbname);
require_once('pqmdconfig.php');
$key = "dbpath";//verpath
$dbname = getConfig($key,$path).$dbname;
}
$dbPath = 'sqlite:'.$dbname;
try {
$conn = new PDO($dbPath);
//$conn->beginTransaction();
} catch(PDOException $e) {
echo 'Exception is:'.$e->getMessage();
}
return $conn;
}
以上是数据库的链接和查询操作
include "shm_offset.php";
include "sqlite.php";
$obj= new sqlitedb();
if ( isset($_GET['page'])) {//翻页处理
if($conn=$obj->conn('../ypm.db')){
$sql = "select max(id) as total from data_3sec ";
$total = $obj->query($conn,$sql);
$total = $total['0']['total'];
$now=$_GET['page']?$_GET['page']:1;
if($now >=$total){$now = $total;}
if($now $list = $now;
$argv = $_GET['argv'];
$argv = explode("|",$argv);
$num = count($argv)-1;
//$sql = "select data,time from data_3sec order by id desc limit ".$list.",1";
$sql = "select data,time,id from data_3sec order by time desc limit 1 offset ".($list-1);
//因为数据量庞大,无法计算总数(卡死),所以改成ID
//dump($sql);
// exit();
$result = $obj->query($conn,$sql);
$data=$result[0]['data'];
// dump($data);
以上是部分查询代码 Call to a member function Execute() on a non-obje 之前是两个数据库是可以运行的,现在改成了一个数据库之后就报这个错误,代码数据库名字方面也该多来了求助各位高手
回复讨论(解决方案)
错误信息指出 Execute 方法不存在,但在你的代码中并未看到在哪里调用了 Execute
错误信息指出 Execute 方法不存在,但在你的代码中并未看到在哪里调用了 Execute
//查询操作
function query($conn,$sql) {
$result = array();
include "shm_offset.php";
if(count($m_fUsys_OffSet) if(strpos($sql,'and')==false && strpos($sql,'line')!==false){
$sql = str_replace('where','',$sql);
}
$sql = str_replace('line','',$sql);
$sql = str_replace('=0','',$sql);
$sql = str_replace('= 0','',$sql);
}
try {
$sth = $conn->prepare($sql);
$sth->execute();
//获取结果
//var_dump($conn);
$result = $sth->fetchAll();
} catch(PDOException $e) {
echo 'Exception is:'.$e->getMessage();
}
return $result;
}
不好意思忘贴了
print_r($conn);
$sth = $conn->prepare($sql);
print_r($sth);
print_r($conn);
$sth = $conn->prepare($sql);
print_r($sth);
只显示了$conn的信息竟然是PDO Object ( )这是没实例化成功?
print_r($conn);
$sth = $conn->prepare($sql);
print_r($sth);
终于知道问题在哪了有个地方数据库名字没改到,真是谢谢了要不是print()还找不到,公司临时给的任务也没学过php

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio

In this article, we're going to explore the notification system in the Laravel web framework. The notification system in Laravel allows you to send notifications to users over different channels. Today, we'll discuss how you can send notifications ov
