为什么我在我的php错误结果中得到这个?我已经标出了发生错误的行。在非对象上调用成员函数query()。
$dbh = new PDO("mysql:host=$hotname_Database;dbname=$database_Database", $username_Database, $password_Database);
$sql = $mysqli->query("SELECT ida FROM finisheddatabase ORDER BY ida DESC LIMIT 1"); //getting error here
$row = mysqli_fetch_array($sql);
$sql = "INSERT INTO finito(hadd, fisa) VALUES(?, ?, ?, ?, ?, ?)";
$q = $dbh->prepare( $sql );
$params = array( $tott, {$row['idz']} );
$q->execute( $params );
答案 0 :(得分:0)
您正在混合访问mysqli界面:第一行使用对象界面,第二行使用功能界面。不要混。
答案 1 :(得分:0)
更改这些行
$sql = $mysqli->query("SELECT ida FROM finisheddatabase ORDER BY ida DESC LIMIT 1");
$row = mysqli_fetch_array($sql);
到
$sql=$dbh->prepare("SELECT ida FROM finisheddatabase ORDER BY ida DESC LIMIT 1");
$row = $dbh->fetch(PDO::FETCH_ASSOC) ;
print_r($row->fetchAll());