Posted by so many sites so little time on 11/24/06 01:05
all right so the script is pretty simple it goes it retrives what the
id of the post is and it lets you edit it well no it doesnt.
now if you go to www.kirewire.com/pp2/index/php you will see a number 1
that is the value of collumn home_id which is set to auto increment ect
ect
but this script which gets the id of home_id of a row and lets you edit
it does not work for somereason...
if (isset ($_POST['submit'])) { // Handle the form.
// Define the query.
$query = "UPDATE home SET header='{$_POST['header']}',
body='{$_POST['body']}' WHERE home_id={$_POST['id']}";
$r = mysql_query ($query); // Execute the query.
// Report on the result.
if (mysql_affected_rows() == 1) {
print '<p>The blog entry has been updated.</p>';
} else {
print "<p>Could update the entry because: <b>" . mysql_error() .
"</b>. The query was $query.</p>";
}
} else { // Display the entry in a form.
// Check for a valid entry ID in the URL.
if (is_numeric ($_GET['id']) ) {
// Define the query.
$query = "SELECT * FROM home_id WHERE home_id={$_GET['id']}";
if ($r = mysql_query ($query)) { // Run the query.
$row = mysql_fetch_array ($r); // Retrieve the information.
// Make the form.
print '<form action="update_site.php" method="post">
<p>Header: <input type="text" name="header" size="40" maxsize="100"
value="' . $row['header'] . '" /></p>
<p>Body: <textarea name="body" columns="40" rows="5">' . $row['body']
.. '</textarea></p>
<input type="hidden" name="id" value="' . $_GET['id'] . '" />
<input type="submit" name="submit" value="Update your Website!" />
</form>';
} else { // Couldn't get the information.
print "<p>Could retrieve the entry because: <b>" . mysql_error() .
"</b>. The query was $query.</p>";
}
} else { // No ID set.
print '<p><b>You must have made a mistake in using this
page.</b></p>';
}
} // End of main IF.
mysql_close(); // Close the database connection.
?>
to see what you get go to www.kirewire.com/pp2/update_site.php
could you please help, thanks, and have a happy thanksgiving
Navigation:
[Reply to this message]
|