|  | Posted by so many sites so little time on 11/22/06 19:56 
ok so i am having problems if you look at the script below you willsee that it the query has 4 values to insert but the actual values only
 contain title entry and now() for the date. well i have made the
 database and the blog_id is a primary auto interger what ever table
 bascly look below the the insert  code block to find the code block
 that makes the table in the database,
 
 
 // Define the query.
 $query = "INSERT INTO blog_entries (blog_id, title, entry,
 date_entered) VALUES ('{$_POST['title']}', '{$_POST['entry']}',
 NOW())";
 
 // Execute the query.
 if (@mysql_query ($query)) {
 print '<p>The blog entry has been added.</p>';
 } else {
 print "<p>Could add the entry because: <b>" . mysql_error() . "</b>.
 The query was $query.</p>";
 }
 
 ---------------------------------------------------------------------------------------------------------------------------------------------------
 
 
 // Define the query.
 $query = 'CREATE TABLE blog_entries (
 blog_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
 title VARCHAR(100) NOT NULL,
 entry 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>');
 }
 
 ---------------------------------------------------------------------------------------------------------------------------------------------
 >>>>blog_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,<<<<
 basicly that right above is what the table looks like now though if i
 go and run the insert script it says that the collumns dont match the
 values ect. but how can i get it to utilize the blog id table?
 what do i enter as a value?
  Navigation: [Reply to this message] |