0
下面的代码是给我这个错误:PHP SQL与多个选择不工作
Call to undefined method mysqli_stmt::get_result() on line 21.
我不明白这是如何工作的对象,为什么我可以做的第一个数据库调用而不是第二。
<?php
header('Content-Type: application/json');
include_once 'do_dbConnect.php';
include_once 'functions.php';
sec_session_start();
//identify who took the last call
$stmt = $mysqli->stmt_init();
if ($stmt->prepare("SELECT MAX(dateOfCall), id FROM call")) { //setup the query statement
$stmt->execute(); //execute the statement
$result = $stmt->get_result(); //get the results
$row = $result->fetch_assoc(); //get the first row
$user_id = $row['id']; //get the id column
}
//identify how many team members there are
if ($stmt->prepare("SELECT id FROM teamMembers")) { //setup the query statement
$stmt->execute(); //execute the statement
$result = $stmt->get_result(); //get the results
$memberCount = $result->num_rows;
}
//get next user
if ($stmt = $mysqli->prepare("SELECT * FROM teamMembers WHERE id = (? + 1) % ?")) { //setup the query statement
$stmt->bind_param('ii', $user_id, $memberCount);
$stmt->execute(); //execute the statement
$result = $stmt->get_result(); //get the results
$row = $result->fetch_assoc(); //get the first row
$next_user_id = $row['id']; //get the id column
$next_user_name = $row['username'];
}
$stmt->close();
//get the next call taker from the teamMember table
echo json_encode($row);
?>
请指定哪些线是21 ??你怎么知道第一个mysqli电话是好的? –
我不知道你的问题的答案,但我总是发现,理解事情的工作往往是最重要的一步。看到这个评论:http://stackoverflow.com/a/8343970/1888402另外,不要害羞,这是一个公共论坛,人们喜欢得到帮助人们的积分,因此这对所有参与者都是双赢的。 –
一个问题是您的第一个查询**调用**是您需要的[* Mysql保留关键字*](http://dev.mysql.com/doc/refman/5.6/en/reserved-words.html)用bact-ticks逃脱它 –