I'm guessing this is another newbie issue. When I update a row, I get the message that the update was successful but there is no change in the database. Here's the code for the update:
<?php
if (isset ($_POST['editContent'])) {
require ("connections/dbconn.php");
$content = $_POST['content'];
$id = $_POST['id'];
$sql = "UPDATE pages SET content='$content' WHERE id='$id'";
$result = $conn->query($sql) or die (mysqli_error());
if ($result){
header("location:admin.php?message=1");
}
}
?>
and here's the code for the admin page with the text editor:
<?php
if(isset ($_GET['message'])){
echo '<font color="red"><strong>You have successfully updated your page </strong></font>';
}
$page = (isset($_GET['page'])) ? $_GET['page'] : "1";
$sql = "SELECT id, content FROM pages WHERE id='$page'";
$result = $conn -> query($sql) or die(mysqli_error());
if($result) {
$row = $result->fetch_object();
echo '<form method="post" action="update.php">';
echo '<textarea name="content" cols="50" rows="15">';
echo '<input type="hidden" name="id" value="'. $row->id .'"';
echo $row->content;
echo '</textarea>';
echo '<input type="submit" name="editContent" value="Update page" />';
echo '</form>';
}
?>
How can I get it to show an error message?