0

这是链接。您需要注册并登录才能查看此页面...您可以使用示例假电子邮件 ID。Thnx :) 我正在使用 PHP SLIM 框架来创建 API 并且代码在 localhost 上运行良好,但它在现场给出以下错误

<b>Fatal error</b>:  Uncaught Error: Call to undefined method mysqli_stmt::get_result() in /home/u474389745/public_html/php_slim/task_manager_angular/api2/include/DbHandler.php:338 Stack trace: #0 /home/u474389745/public_html/php_slim/task_manager_angular/api2/v1/index.php(175): DbHandler-&gt;getAllUserTasks(29) #1 [internal function]: {closure}() #2 /home/u474389745/public_html/php_slim/task_manager_angular/api2/libs/Slim/Route.php(436): call_user_func_array(Object(Closure), Array) #3 /home/u474389745/public_html/php_slim/task_manager_angular/api2/libs/Slim/Slim.php(1307): Slim\Route-&gt;dispatch() #4 /home/u474389745/public_html/php_slim/task_manager_angular/api2/libs/Slim/Middleware/Flash.php(85): Slim\Slim-&gt;call() #5 /home/u474389745/public_html/php_slim/task_manager_angular/api2/libs/Slim/Middleware/MethodOverride.php(92): Slim\Middleware\Flash-&gt;call() #6 /home/u474389745/public_html/php_slim/task_manager_angular/api2/libs/Slim/Middleware/PrettyExceptions.php(67): Slim\Middleware\MethodOverride-&gt;call() #7 /home/u474389745/public_h in  <b>/home/u474389745/public_html/php_slim/task_manager_angular/api2/include/DbHandler.php</b> on line <b>338</b><br />

下面是我的函数调用

$app->get('/tasks', 'authenticate', function() {
        global $user_id;
        $response = array();
        $db = new DbHandler();

        // fetching all user tasks
        //line no 175 of index.php error detected by debug tool
        $result = $db->getAllUserTasks($user_id);

        $response["error"] = false;
        $response["tasks"] = array();

        // looping through result and preparing tasks array
        while ($task = $result->fetch_assoc()) {
            $tmp = array();
            $tmp["id"] = $task["id"];
            $tmp["task"] = $task["task"];
            $tmp["status"] = $task["status"];
            $tmp["createdAt"] = $task["created_at"];
            array_push($response["tasks"], $tmp);
        }

        echoRespnse(200, $response);
    });

我在这里获取所有数据

public function getAllUserTasks($user_id) {
     $stmt = $this->conn->prepare("SELECT t.* FROM tasks t, user_tasks ut WHERE t.id = ut.task_id AND ut.user_id = ?");
     $stmt->bind_param("i", $user_id);
     $stmt->execute();
     //line no 338 in DbHandler.php error detected by debug tool
     $tasks = $stmt->get_result();
     $stmt->close();
     return $tasks;
 }

//在 338 行 DbHandler.php $tasks = $stmt->get_result();

请检查角度函数

$scope.get_all_task = function(add){
    $http({
    method: 'GET',
    url: 'api2/v1/tasks',
    crossDomain: true,
    dataType: "json",
    contentType: 'application/json',
    headers: {'authorization': localStorage.getItem("login_api_angular"),'Content-Type': 'application/x-www-form-urlencoded'},

    }).success(function (response, data, textStatus, jqXHR) {

        console.log(response.tasks);  
        console.log(textStatus);
        console.log(jqXHR);     
        $scope.task1 = response.tasks;


    }).error(function (response, data, textStatus, jqXHR) {
        console.log(response.message);  
        angular.element(document.getElementById('data_info_p')).append(response.message+' Please Login');
    });       
};

这是html部分

<table data-ng-controller="authCtrl" data-ng-init="get_all_task()" width="100%"><tbody id="data_info_p"><tr ng-repeat="task22 in task1">
<td>{{task22.task}}</td></tr></tbody></table>
4

0 回答 0