首先,我将BedrijfID从会议中删除
$Deals = $_SESSION['login'];
$sSql = "SELECT BedrijfID FROM tblBedrijf WHERE Email = '$Deals'";
$res = $conn->query($sSql);
return $res;
我需要把它放在另一张表中
$sql = "INSERT INTO tblDeal (Dealnaam, Dealkeuze, Dealbeschrijving,BedrijfID)
VALUES
(
'" . $conn -> real_escape_string($this -> m_sNaamdeal) . "',
'" . $conn -> real_escape_string($this -> m_sAantal) . "',
'" . $conn -> real_escape_string($this -> m_sBeschrijving) . "',
'" . $conn -> real_escape_string($res) . "'
);";
错误:
警告:mysqli :: real_escape_string()期望参数1为字符串,对象在/
中给出
答案 0 :(得分:2)
您需要先获取一行:
$Deals = $_SESSION['login'];
$sSql = "SELECT BedrijfID FROM tblBedrijf WHERE Email = '$Deals'";
$res = $conn->query($sSql);
$row = $res->fetch_assoc();
$sql = "INSERT INTO tblDeal (Dealnaam, Dealkeuze, Dealbeschrijving,BedrijfID)
VALUES
(
'" . $conn -> real_escape_string($this -> m_sNaamdeal) . "',
'" . $conn -> real_escape_string($this -> m_sAantal) . "',
'" . $conn -> real_escape_string($this -> m_sBeschrijving) . "',
'" . $conn -> real_escape_string($row['BedrijfID']) . "'
);";