所以,我正在我的网站上工作。 10分钟后我就准备好了。我尝试过这个。我的数据库中有4列。 id
,times
,left_over
和bruh
。当我尝试它时,一切都被插入但不是bruh
,我不知道我做错了什么。这是我的剧本:
$link = mysqli_connect("localhost", "root", "", "testang");
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$channelid = mysqli_real_escape_string($link, $_POST['channelid']);
$subs = mysqli_real_escape_string($link, $_POST['subs']);
$points = $subs*20;
$lell = $userRow['userid'];
$lel = $userRow['userpoints'];
$pointsreal = $lel - $points;
if ($points > $lel) {
header("Refresh:0; url=NO.php");
}
$bew = "INSERT INTO yt (times, left_over, bruh)
VALUES ('0', '$subs', '$channelid')";
if ($link->query($bew) === TRUE) {
echo "";
} else {
echo "Error: " . $bew . "<br>" . $link->error;
}
mysqli_close($link);
而且我没有收到任何有关错误的消息。一切都插入了,但bruh
没有。有人知道为什么吗?
这是我的表格:
<form action="insert.php" method="post">
<p>
<label for="firstName">Youtube channel ID</label><br>
<input type="text" name="id" id="channelid">
</p><br><br>
<p>
<label for="lastName">What is your email?</label><br>
<input type="text" name="subs" id="subs">
</p><br><br>
<input type="submit" value="Submit">
</form>
答案 0 :(得分:1)
现在我从评论中知道什么是错的,让我在这里澄清一下有什么不对。在你的领域:
<input type="text" name="id" id="channelid">
您有ID:channelid
和姓名:id
。为了能够获得$_POST['channelid']
,您需要使用与name
索引中相同的字符串设置属性$_POST
。因此:
<input type="text" name="channelid" id="channelid">