|
Posted by so many sites so little time on 11/19/06 16:06
this is the print out from phpmyadmin if you have used that before this
might help you understand the structure of the table
home:
Field Type Null Default
home_id int(10) No
header varchar(100) No
body text No
date_entered datetime No 0000-00-00 00:00:00
Indexes:
Keyname Type Cardinality Field
PRIMARY PRIMARY 0 home_id
Space usage:
Type Usage
Data 0 B
Index 1,024 B
Total 1,024 B
Row Statistics:
Statements Value
Format dynamic
Rows 0
Next Autoindex 1
Creation Nov 19, 2006 at 10:43 AM
Last update Nov 19, 2006 at 10:43 AM
so many sites so little time wrote:
> to me it looks like the dateentered and the home id arent being entered
> into the database correct?
> so many sites so little time wrote:
> > 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]
|