ik ben een cms systeem aan het maken. Om een pagina te bewerken gebruik in dezelfde code. Op de ene pagina werkt het wel en op de andere pagina krijg ik de fout melding.
dit is het script dat wel werkt:
<?php
$res = mysqli_query($link, "select * from homepage");
echo "<form action ='php/updatehome.php' method='POST'>";
while ($row = mysqli_fetch_assoc($res))
{
echo "<input type='hidden' name='id' value='".$row['id']."'>";
echo "<div class='content'>";
echo "<textarea name='text'>";
echo $row['tekst'];
echo "</textarea></div>";
}
echo "<input type='submit' value='Bewerk'></form>";
?>
<?php
$link = mysqli_connect("localhost", "root", "root", "faith") or die ("error");
$id = $_POST['id'];
$text = $_POST['text'];
$res = mysqli_query ($link, "UPDATE homepage SET tekst = '$text' WHERE homepage.id='$id'");
if($res){
header("Location:../index.php");
}else{
echo "It doesn't work";
}
?>
en deze werkt niet:
<?php
$res = mysqli_query($link, "select * from wij");
echo "<form action ='php/updatewij.php' method='POST'>";
while ($row = mysqli_fetch_assoc($res))
{
echo "<input type='hidden' name='id' value='".$row['id']."'>";
echo "<div class='content'>";
echo "<textarea name='text'>";
echo $row['tekst'];
echo "</textarea></div>";
}
echo "<input type='submit' value='Bewerk'></form>";
?>
<?php
$link = mysqli_connect("localhost", "root", "root", "faith") or die ("error");
$id = $_POST['id'];
$text = $_POST['text'];
$res = mysqli_query ($link, "UPDATE wij SET tekst = '$text' WHERE homepage.id='$id'");
if($res)
{
header("Location:../index.php");
}
else
{
echo "It doesn't work";
}
?>
1.490 views