gpt4 book ai didi

php - 警告:mysqli::query():空查询

转载 作者:行者123 更新时间:2023-11-29 04:21:19 26 4
gpt4 key购买 nike

<分区>

对于我的应用程序,我正在创建一个成员可以订阅的组。使用函数 CreateGroup,我正在将数据写入数据库。使用 sql '$insert' 我正在将数据写入 tblgroups。没关系

使用 sql '$insertmember' 我试图将数据发送到 tblgroup_member 但是 group_idgroupmember_id 不会填满。

group_id 必须是最后创建的组的 id_number。因此我正在使用 sql '$latest'。之后,我正在执行 fetch_assoc 以获取号码。

但是我得到的错误是 $latestresult is undefined en mysqli::query 是空的?我做错了什么?

PHP

$user_id = $user -> getUserByEmail($email);

if(isset($_POST["btnCreateGroup"])){
try {
$group = new Group();

$distance = (isset($_POST["distance"])) ? $_POST["distance"] : '';
$groupname = (isset($_POST["groupname"])) ? $_POST["groupname"] : '';
$duration = (isset($_POST["duration"])) ? $_POST["duration"] : '';

$group->GroupDistance = mysql_real_escape_string($distance);
$group->GroupName = mysql_real_escape_string($groupname);
$group->GroupDuration = mysql_real_escape_string($duration);
$group->CreatorId = mysql_real_escape_string($user_id);
$group->CreateGroup();
//$group->SaveCreatoridToGroup();

} catch(exception $e) {
$feedback = $e -> getMessage();
}

功能

public function CreateGroup()
{

$db = new Db();

$insert = "INSERT INTO tblgroups (
group_name,
group_distance,
group_duration,
group_creator_id

) VALUES (
'" . $db->conn->real_escape_string($this->m_sGroupName) . "',
'" . $db->conn->real_escape_string($this->m_iGroupDistance) . "',
'" . $db->conn->real_escape_string($this->m_iGroupDuration) . "',
'" . $db->conn->real_escape_string($this->m_sCreatorId) . "'
)";

$db -> conn -> query($insert);


$latest = "SELECT group_id FROM tblgroups ORDER BY group_id desc limit 1";
$latestresult = $db->conn->query($latestresult);
$fetch_latestresult = mysqli_fetch_assoc($latestresult);
var_dump($latestresult);

$insertmember = "INSERT INTO tblgroup_member (
group_id,
groupmember_id

) VALUES (
'" . $db->conn->real_escape_string($fetch_latestresult) . "',
'" . $db->conn->real_escape_string($this->m_sCreator_id) ."'
)";

$db -> conn -> query($insertmember);
throw new Exception("You created a group!");

}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com