|
Posted by so many sites so little time on 11/19/06 15:57
this time i am going to use the scripts from the book and just change
the names to match what i am trying to do now i just got an error that
i know shouldnt be an error i think. this is the error:
Could add the site entry because: Column count doesn't match value
count at row 1. The query was INSERT INTO home (home_id, header, body,
date_entered) VALUES ('Welcome!', 'What is a Progressive Parent? A
Progressive Parent ...
now i created the table using what the book gave me which is:
// Define the query.
$query = 'CREATE TABLE home (
home_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
header VARCHAR(100) NOT NULL,
body TEXT NOT NULL,
date_entered DATETIME NOT NULL
)';
// Run the query.
if (@mysql_query ($query)) {
print '<p>The table has been created.</p>';
} else {
die ('<p>Could not create the table because: <b>' . mysql_error() .
'</b>.</p><p>The query being run was: ' . $query . '</p>');
}
and when i ran that script live i got the message "The table has been
created."
now when i run this script and try to insert the data is when i get the
error message i posted above and that script looks like:
// Define the query.
$query = "INSERT INTO home (home_id, header, body, date_entered)
VALUES ('{$_POST['header']}', '{$_POST['body']}', NOW())";
// Execute the query.
if (@mysql_query ($query)) {
print '<p>The site entry has been added.</p>';
} else {
print "<p>Could add the site entry because: <b>" . mysql_error() .
"</b>. The query was $query.</p>";
}
mysql_close();
}
// Display the form.
?>
<form action="edit_site.php" method="post">
<p>Entry Title: <input type="text" name="header" size="40"
maxsize="100" /></p>
<p>Entry Text: <textarea name="body" cols="40" rows="5"></textarea></p>
<input type="submit" name="submit" value="Add to the Site" />
</form>
Navigation:
[Reply to this message]
|