[英]php variable not working within else function
所以我在php中使用sql,但是一个变量不起作用。 works in the but not within the . 变量可在但不能在 。 . 其他变量也起作用 。 谁能发现错误?
(对不起,我的英语有任何错误。)
<?php
$bericht = $_POST ['bericht'];
$pagina = $_GET ['id'];
$naam = $_SESSION['login'];
$con = mysqli_connect("host","sql","pw","sql");
if (empty($bericht)) {
}
else
{
$sql2="INSERT INTO Comments (bericht_id, naam, bericht) VALUES ('$pagina', '$naam', '$bericht')";
mysqli_query($con,$sql2);
header("location:directbericht.php?id=$pagina");
}
$sql="SELECT * FROM Berichten WHERE id = $pagina";
if ($result=mysqli_query($con,$sql))
{
while ($obj=mysqli_fetch_object($result))
{
echo $obj->naam;
echo "<br><br>";
echo $obj->bericht;
echo "<br><br>";
echo $obj->datum;
echo "<br><br>";
}
}
$sql="SELECT * FROM Comments WHERE bericht_id = $pagina ORDER BY id ASC";
if ($result=mysqli_query($con,$sql))
{
while ($obj=mysqli_fetch_object($result))
{
echo "<tr><td><font color='white'>";
echo $obj->naam;
echo "<br><br>";
echo $obj->bericht;
echo "<br><br>";
echo $obj->datum;
echo "<br><br>";
echo "</font></tr></td>";
}
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.