【问题标题】:Fatal error: Uncaught Error: Call to undefined method mysqli::execute()致命错误:未捕获的错误:调用未定义的方法 mysqli::execute()
【发布时间】:2021-04-17 04:31:01
【问题描述】:

我正在学习 php。我收到此错误

致命错误:未捕获错误:调用 C:\xampp\htdocs\search\index.php:58 中未定义的方法 mysqli::execute() 堆栈跟踪:#0 {main} 在 C:\xampp\htdocs 中抛出\search\index.php 第 58 行

这里是第 58 行

<?php
    include'config.php';
    $stmt=$conn->prepare("SELECT * FROM info");
    $conn->execute(); // This line
    $result=$stmt->get_result();
 ?>                            

我正在尝试创建一个简单的实时搜索。

【问题讨论】:

  • 您正在尝试“执行”您的连接,您需要改为执行该语句。
  • 哦,是的,谢谢。它现在正在工作。

标签: php mysqli


【解决方案1】:

改为在$stmt 对象上调用execute() 方法。

 include 'config.php';
 $stmt = $conn->prepare("SELECT * FROM info");
 $stmt->execute(); // you are executing connection here
 $result = $stmt->get_result();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-21
    • 1970-01-01
    • 1970-01-01
    • 2019-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    相关资源
    最近更新 更多