you dont need to have a list of field names if you insert
the exact amount of fields that exist in the table...

if you have fields Name and Email, you can do:
INSERT INTO mytable VALUES ('myname','[EMAIL PROTECTED]')
without a problem.  however, if you have fields 
Name, Email and Password the previous code will break,
since MySQL would complain that you're inserting
too few (or too many) pieces of data into the table,
and it cant decide which data goes where

> -----Original Message-----
> From: Joe Stump [mailto:[EMAIL PROTECTED]]
> Sent: Friday, February 23, 2001 17:21
> To: Clayton Dukes
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] Help INSERTing to MySQL
> 
> 
> Before your VALUES you need to have a list of the fields ie:
> 
> insert into table (id,fname,lname) values ('$id','$fname','$lname')
> 
> --joe
> 
> On Fri, Feb 23, 2001 at 08:00:30PM -0500, Clayton Dukes wrote:
> > Hello,
> > This is my first attempt, so I'm prolly doing something stupid, but can 
> someone tell me why this doesn't work?
> > All it returns is "Unable to INSERT to database"
> > 
> > 
> > 
> > ---BEGIN---
> > <?
> >    $time = time();
> >    $rand = Random_Password(5);
> >    $docid = $time . $rand;
> > 
> >     if (isset($email) && isset($docid)) {
> >         mysql_connect("$HOSTNAME", "$DB_USER", "$DB_PASS");
> > 
> >    $query = "INSERT INTO documents VALUES ('$docid', '$category', 
> '$subcategory', '$date', '$subject', '$title', '$author', '$email', 
> '$language', '$gr
> > ade', '$level', '$city', '$state', '$county', '$zip', 
> '$authors_comments', '$teachers_comments', 'N', '$docdata')";
> > 
> >    $result = mysql_db_query("$DATABASE", $query) or die("Unable to 
> INSERT to database");
> > 
> >     if ($result) {
> >         echo "<p>$docid was added to the database</p>";
> >     }
> > }
> > ?>
> > 
> >      <h1>Submit a new document to the database</h1>
> >          <form>
> >          Email Address: <input type=text name=email><br>
> >          Category: <select name=category><? print "$CATEGORIES" ?></select><br>
> >          Sub Category: <select name=subcategory><? print 
> "$SUBCATEGORIES" ?></select><br>
> >          Date Document was written: <input type=text name=date> (xx-xx-xxxx)<br>
> >          Document Subject: <input type=text name=subject><br>
> >          Document Title: <input type=text name=title><br>
> >          Document Author: <input type=text name=author><br>
> >          Document Language: <input type=text name=language value=English><br>
> >          Grade Received (Percentage): <input type=text name=grade 
> size=3> (xx/100)<br>
> >          Grade Level of Paper: <select name=level><option>High 
> School</option><option>College</option><option>Other</option></select><br>
> >          City in which paper was submitted: <input type=text name=city 
> value=Jacksonville><br>
> >          State in which paper was submitted: <input type=text name=state 
> value=FL><br>
> >          County in which paper was submitted: <input type=text 
> name=county value=Duval> <b>(County, not Country!)</b><br>
> >          School at which paper was submitted: <input type=text 
> name=school value="Mandarin High School"><br>
> >          ZIP code: <input type=text name=zip size=5 value=32257> <b>(Put 
> your ZIP code in if you don't know your school's)</b><br>
> >          Author's Comments: <input type=text name=authors_comments><br>
> >          Teacher's Comments: <input type=text name=teachers_comments><br>
> >          Document (ASCII TEXT ONLY):<br>
> >          <textarea name=docdata cols=80 rows=30>Paste document text 
> here</textarea>
> >          <p><input type=submit value="Submit for verification">
> >          </form>
> > 
> > -----END-----
> > 
> > 
> > 
> > TIA!
> > Clayton
> > 
> 
> > -- 
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> -- 
> 
> -------------------------------------------------------------------------------
> Joe Stump, PHP Hacker, [EMAIL PROTECTED]                                 -o)
> http://www.miester.org http://www.care2.com                                 /\\
> "It's not enough to succeed. Everyone else must fail" -- Larry Ellison     _\_V
> -------------------------------------------------------------------------------
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to