![](/img/trans.png)
[英]Fatal error: Call to a member function extend() on a non-object in /***/***/public_html/lib/Varien/Simplexml/Config.php on line 600
[英]Fatal error: Call to a member function execute() on a non-object in /public_html/website/index.php on line
我想從數據庫中獲取數據。 我收到以下錯誤消息。 問題是,下面的代碼在我的其他項目中使用了,並且運行良好。 有人知道問題出在哪里嗎?
我收到此錯誤:
Fatal error: Call to a member function execute() on a non-object in /public_html/website/index.php on line
碼:
include 'scripts/db_conn.php';
include 'scripts/functions.php';
$prep_stmt = "SELECT date FROM blocked_dates WHERE date >= CURDATE();";
$stmt = $mysqli->prepare($prep_stmt);
$stmt->execute();
if (!$stmt) {
die('There was an error running the query [' . $mysqli->error . ']');
exit();
}
$meta = $stmt->result_metadata();
while ($field = $meta->fetch_field()) {
$parameters[] = & $row[$field->name];
}
call_user_func_array(array($stmt, 'bind_result'), $parameters);
while ($stmt->fetch()) {
foreach ($row as $key => $val) {
$x[$key] = $val;
}
$results[] = $x;
}
您不能將對象綁定到新變量。
嘗試像這樣啟動您的代碼:
$stmt = new Mysqli();
連接到數據庫后,
$stmt->prepare($prep_stmt);
$debug = $stmt->execute();
if (!$debug) {
die('There was an error running the query [' . $mysqli->error . ']');
exit();
}
$meta = $stmt->result_metadata();
while ($field = $meta->fetch_field()) {
$parameters[] = & $row[$field->name];
}
call_user_func_array(array($stmt, 'bind_result'), $parameters);
while ($stmt->fetch()) {
foreach ($row as $key => $val) {
$x[$key] = $val;
}
$results[] = $x;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.