[PHP] Help INSERTing to MySQL

2001-02-23 Thread Clayton Dukes



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', '$grade', '$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"; }}?

 h1Submit a new 
document to the 
database/h1 
form Email Address: 
input type=text 
name=emailbr 
Category: select name=category? print "$CATEGORIES" 
?/selectbr 
Sub Category: select name=subcategory? print "$SUBCATEGORIES" 
?/selectbr 
Date Document was written: input type=text name=date 
(xx-xx-)br 
Document Subject: input type=text 
name=subjectbr 
Document Title: input type=text 
name=titlebr 
Document Author: input type=text 
name=authorbr 
Document Language: input type=text name=language 
value=Englishbr 
Grade Received (Percentage): input type=text name=grade size=3 
(xx/100)br Grade 
Level of Paper: select name=leveloptionHigh 
School/optionoptionCollege/optionoptionOther/option/selectbr 
City in which paper was submitted: input type=text name=city 
value=Jacksonvillebr 
State in which paper was submitted: input type=text name=state 
value=FLbr 
County in which paper was submitted: input type=text name=county 
value=Duval b(County, not 
Country!)/bbr 
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)/bbr 
Author's Comments: input type=text 
name=authors_commentsbr 
Teacher's Comments: input type=text 
name=teachers_commentsbr 
Document (ASCII TEXT 
ONLY):br 
textarea name=docdata cols=80 rows=30Paste document text 
here/textarea 
pinput 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]


Re: [PHP] Help INSERTing to MySQL

2001-02-23 Thread Joe Stump

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";
 }
 }
 ?
 
  h1Submit a new document to the database/h1
  form
  Email Address: input type=text name=emailbr
  Category: select name=category? print "$CATEGORIES" ?/selectbr
  Sub Category: select name=subcategory? print "$SUBCATEGORIES" 
?/selectbr
  Date Document was written: input type=text name=date (xx-xx-)br
  Document Subject: input type=text name=subjectbr
  Document Title: input type=text name=titlebr
  Document Author: input type=text name=authorbr
  Document Language: input type=text name=language value=Englishbr
  Grade Received (Percentage): input type=text name=grade size=3 
(xx/100)br
  Grade Level of Paper: select name=leveloptionHigh 
School/optionoptionCollege/optionoptionOther/option/selectbr
  City in which paper was submitted: input type=text name=city 
value=Jacksonvillebr
  State in which paper was submitted: input type=text name=state 
value=FLbr
  County in which paper was submitted: input type=text name=county 
value=Duval b(County, not Country!)/bbr
  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)/bbr
  Author's Comments: input type=text name=authors_commentsbr
  Teacher's Comments: input type=text name=teachers_commentsbr
  Document (ASCII TEXT ONLY):br
  textarea name=docdata cols=80 rows=30Paste document text here/textarea
  pinput 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]




Re: [PHP] Help INSERTing to MySQL

2001-02-23 Thread Philip Olson


 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"

Change : or die("Unable to INSERT to database");
To : or die(mysql_error());

And see what it tells you.  Odds are there's a field not being accounted
for.  When not designating columns (just values) it's important to make
sure all columns are accounted for.  See :

http://www.sqlcourse.com/

It'll provide some basic SQL help.  It's recommended to write out columns
and values (easier to make sense of).


Regards,

Philip Olson
http://www.cornado.com/
 
 
 
 ---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";
 }
 }
 ?


-- 
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]




Re: [PHP] Help INSERTing to MySQL

2001-02-23 Thread Clayton Dukes

Well sheesh,
If I knew I could get answers that easy here, I woudn't have worked on this
for 20 hours :-)

THANKS

btw, field one is an ID field set to auto increment, how can I insert that
if I don't know what it is?


Here are the fields:
CREATE TABLE documents (
  id bigint(20) DEFAULT '0' NOT NULL auto_increment,
  docid varchar(20),
  category enum('Language Arts','Sciences','Humanities','Arts','Special
Subjects','Other'),
  subcategory enum('Physics','Biology','Chemistry','Math','Computers and
Internet','History','Economics','Geography','Law','Religion','Philosophy','B
lack Awareness','Countries','Drugs','Education','Environmental
Awareness','Politics','Health','Sex and Sexuality','Female
Awareness','Art','Movies or TV','Music','Sports','Charles
Dickens','Shakespeare','Biography','Fictional
Stories','Astronomy','Mythology'),
  date varchar(10),
  subject varchar(200),
  title varchar(200),
  author varchar(200),
  email varchar(50),
  language enum('English','Danish','Dutch','Finnish','German','Spanish'),
  grade int(3),
  level enum('High School','College','Other'),
  city varchar(15),
  state varchar(15),
  county varchar(15),
  school varchar(45),
  zip smallint(5),
  authorcomments varchar(200),
  teachercomments varchar(200),
  approve enum('Y','N'),
  docdata text,
  PRIMARY KEY (id),
  UNIQUE id (id)


- Original Message -
From: "Philip Olson" [EMAIL PROTECTED]
To: "Clayton Dukes" [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Friday, February 23, 2001 8:31 PM
Subject: Re: [PHP] Help INSERTing to MySQL



  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"

 Change : or die("Unable to INSERT to database");
 To : or die(mysql_error());

 And see what it tells you.  Odds are there's a field not being accounted
 for.  When not designating columns (just values) it's important to make
 sure all columns are accounted for.  See :

 http://www.sqlcourse.com/

 It'll provide some basic SQL help.  It's recommended to write out columns
 and values (easier to make sense of).


 Regards,

 Philip Olson
 http://www.cornado.com/

 
 
  ---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";
  }
  }
  ?


 --
 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]




Re: [PHP] Help INSERTing to MySQL

2001-02-23 Thread Kyndig

On Fri, 23 Feb 2001, Clayton Dukes wrote:
 Well sheesh,
 If I knew I could get answers that easy here, I woudn't have worked on this
 for 20 hours :-)
 
 THANKS
 
 btw, field one is an ID field set to auto increment, how can I insert that
 if I don't know what it is?

You don't need to insert it. auto_increment will automatically
increment every time you insert a record. In fact, you _really_
don't want to ever set this field, as you would be modifying your
primary key ( unless your modifying them all )

 Note: You don't have to INSERT all fields mentioned below. If
you have a 'default' value set..then it will default to that value,
or in auto_increment case...it will automatically increment from
the last record it reads.

 
 Here are the fields:
 CREATE TABLE documents (
   id bigint(20) DEFAULT '0' NOT NULL auto_increment,
   docid varchar(20),
   category enum('Language Arts','Sciences','Humanities','Arts','Special
 Subjects','Other'),
   subcategory enum('Physics','Biology','Chemistry','Math','Computers and
 Internet','History','Economics','Geography','Law','Religion','Philosophy','B
 lack Awareness','Countries','Drugs','Education','Environmental
 Awareness','Politics','Health','Sex and Sexuality','Female
 Awareness','Art','Movies or TV','Music','Sports','Charles
 Dickens','Shakespeare','Biography','Fictional
 Stories','Astronomy','Mythology'),
   date varchar(10),
   subject varchar(200),
   title varchar(200),
   author varchar(200),
   email varchar(50),
   language enum('English','Danish','Dutch','Finnish','German','Spanish'),
   grade int(3),
   level enum('High School','College','Other'),
   city varchar(15),
   state varchar(15),
   county varchar(15),
   school varchar(45),
   zip smallint(5),
   authorcomments varchar(200),
   teachercomments varchar(200),
   approve enum('Y','N'),
   docdata text,
   PRIMARY KEY (id),
   UNIQUE id (id)
 
 
 - Original Message -
 From: "Philip Olson" [EMAIL PROTECTED]
 To: "Clayton Dukes" [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Sent: Friday, February 23, 2001 8:31 PM
 Subject: Re: [PHP] Help INSERTing to MySQL
 
 
 
   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"
 
  Change : or die("Unable to INSERT to database");
  To : or die(mysql_error());
 
  And see what it tells you.  Odds are there's a field not being accounted
  for.  When not designating columns (just values) it's important to make
  sure all columns are accounted for.  See :
 
  http://www.sqlcourse.com/
 
  It'll provide some basic SQL help.  It's recommended to write out columns
  and values (easier to make sense of).
 
 
  Regards,
 
  Philip Olson
  http://www.cornado.com/
 
  
  
   ---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";
   }
   }
   ?
 
 
  --
  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]
-- 
Kind Regards,
---
Kyndig
Online Text Game Resource Site:  http://www.kyndig.com
ICQ#10451240


-- 
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]




Re: [PHP] Help INSERTing to MySQL

2001-02-23 Thread Clayton Dukes

Thanks! :-)

Man, what a great list! You guys kick a$$



- Original Message -
From: "Kyndig" [EMAIL PROTECTED]
To: "Clayton Dukes" [EMAIL PROTECTED]; "Philip Olson" [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Friday, February 23, 2001 8:50 PM
Subject: Re: [PHP] Help INSERTing to MySQL


 On Fri, 23 Feb 2001, Clayton Dukes wrote:
  Well sheesh,
  If I knew I could get answers that easy here, I woudn't have worked on
this
  for 20 hours :-)
 
  THANKS
 
  btw, field one is an ID field set to auto increment, how can I insert
that
  if I don't know what it is?
 
 You don't need to insert it. auto_increment will automatically
 increment every time you insert a record. In fact, you _really_
 don't want to ever set this field, as you would be modifying your
 primary key ( unless your modifying them all )

  Note: You don't have to INSERT all fields mentioned below. If
 you have a 'default' value set..then it will default to that value,
 or in auto_increment case...it will automatically increment from
 the last record it reads.

 
  Here are the fields:
  CREATE TABLE documents (
id bigint(20) DEFAULT '0' NOT NULL auto_increment,
docid varchar(20),
category enum('Language Arts','Sciences','Humanities','Arts','Special
  Subjects','Other'),
subcategory enum('Physics','Biology','Chemistry','Math','Computers and
 
Internet','History','Economics','Geography','Law','Religion','Philosophy','B
  lack Awareness','Countries','Drugs','Education','Environmental
  Awareness','Politics','Health','Sex and Sexuality','Female
  Awareness','Art','Movies or TV','Music','Sports','Charles
  Dickens','Shakespeare','Biography','Fictional
  Stories','Astronomy','Mythology'),
date varchar(10),
subject varchar(200),
title varchar(200),
author varchar(200),
email varchar(50),
language
enum('English','Danish','Dutch','Finnish','German','Spanish'),
grade int(3),
level enum('High School','College','Other'),
city varchar(15),
state varchar(15),
county varchar(15),
school varchar(45),
zip smallint(5),
authorcomments varchar(200),
teachercomments varchar(200),
approve enum('Y','N'),
docdata text,
PRIMARY KEY (id),
UNIQUE id (id)
 
 
  - Original Message -
  From: "Philip Olson" [EMAIL PROTECTED]
  To: "Clayton Dukes" [EMAIL PROTECTED]
  Cc: [EMAIL PROTECTED]
  Sent: Friday, February 23, 2001 8:31 PM
  Subject: Re: [PHP] Help INSERTing to MySQL
 
 
  
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"
  
   Change : or die("Unable to INSERT to database");
   To : or die(mysql_error());
  
   And see what it tells you.  Odds are there's a field not being
accounted
   for.  When not designating columns (just values) it's important to
make
   sure all columns are accounted for.  See :
  
   http://www.sqlcourse.com/
  
   It'll provide some basic SQL help.  It's recommended to write out
columns
   and values (easier to make sense of).
  
  
   Regards,
  
   Philip Olson
   http://www.cornado.com/
  
   
   
---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";
}
}
?
  
  
   --
   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]
 --
 Kind Regards,
 ---
 Kyndig
 Online Text Game Resource Site:  http://www.kyndig.com
 ICQ# 10451240


-- 
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]




Re: [PHP] Help INSERTing to MySQL

2001-02-23 Thread php3

Addressed to: Clayton Dukes [EMAIL PROTECTED]
  [EMAIL PROTECTED]

** Reply to note from Philip Olson [EMAIL PROTECTED] Sat, 24 Feb 2001 01:31:30 
+ (GMT)


  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"

 Change : or die("Unable to INSERT to database");
 To : or die(mysql_error());

 And see what it tells you.  Odds are there's a field not being accounted
 for.  When not designating columns (just values) it's important to make
 sure all columns are accounted for.  See :

 http://www.sqlcourse.com/

 It'll provide some basic SQL help.  It's recommended to write out columns
 and values (easier to make sense of).

I find SET even easier:


   INSERT INTO Table SET

or

   UPDATE Table SET


then

  field1 = '$Field1',
  field2 = '$Field2',
  fieldN = '$FieldN'


That makes it very easy to keep track of what goes where.  It is
somewhat new to MySQL, but anything less than a year old should have it
available.




Rick Widmer
Internet Marketing Specialists
http://www.developersdesk.com

--
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]




Re: [PHP] Help INSERTing to MySQL

2001-02-23 Thread Philip Olson


 If I knew I could get answers that easy here, I woudn't have worked on this
 for 20 hours :-)
 
 THANKS
 
 btw, field one is an ID field set to auto increment, how can I insert that
 if I don't know what it is?

In this case use NULL as the value for id and it'll auto increment nicely.
Using a blank  ''  will work too.  Regarding use of NULL, it's NULL and
not 'NULL'.

Regards,

Philip


-- 
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]




RE: [PHP] Help INSERTing to MySQL

2001-02-23 Thread ..s.c.o.t.t..

0 also works for AUTO_INCREMENT fields...

 -Original Message-
 From: Philip Olson [mailto:[EMAIL PROTECTED]]
 Sent: Friday, February 23, 2001 18:41
 To: Clayton Dukes
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] Help INSERTing to MySQL
 
 
 
  If I knew I could get answers that easy here, I woudn't have worked on this
  for 20 hours :-)
  
  THANKS
  
  btw, field one is an ID field set to auto increment, how can I insert that
  if I don't know what it is?
 
 In this case use NULL as the value for id and it'll auto increment nicely.
 Using a blank  ''  will work too.  Regarding use of NULL, it's NULL and
 not 'NULL'.
 
 Regards,
 
 Philip
 
 
 -- 
 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]




RE: [PHP] Help INSERTing to MySQL

2001-02-23 Thread ..s.c.o.t.t..

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";
  }
  }
  ?
  
   h1Submit a new document to the database/h1
   form
   Email Address: input type=text name=emailbr
   Category: select name=category? print "$CATEGORIES" ?/selectbr
   Sub Category: select name=subcategory? print 
 "$SUBCATEGORIES" ?/selectbr
   Date Document was written: input type=text name=date (xx-xx-)br
   Document Subject: input type=text name=subjectbr
   Document Title: input type=text name=titlebr
   Document Author: input type=text name=authorbr
   Document Language: input type=text name=language value=Englishbr
   Grade Received (Percentage): input type=text name=grade 
 size=3 (xx/100)br
   Grade Level of Paper: select name=leveloptionHigh 
 School/optionoptionCollege/optionoptionOther/option/selectbr
   City in which paper was submitted: input type=text name=city 
 value=Jacksonvillebr
   State in which paper was submitted: input type=text name=state 
 value=FLbr
   County in which paper was submitted: input type=text 
 name=county value=Duval b(County, not Country!)/bbr
   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)/bbr
   Author's Comments: input type=text name=authors_commentsbr
   Teacher's Comments: input type=text name=teachers_commentsbr
   Document (ASCII TEXT ONLY):br
   textarea name=docdata cols=80 rows=30Paste document text 
 here/textarea
   pinput 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]