Slight error here if you want the auto icrement field to work properly

On Wed, 3 Oct 2001, Chris Johnson wrote:

> Date: Wed, 3 Oct 2001 20:07:49 -0500
> From: Chris Johnson <[EMAIL PROTECTED]>
> To: Russell Miller <[EMAIL PROTECTED]>, sjs <[EMAIL PROTECTED]>,
>     [EMAIL PROTECTED]
> Subject: Re: very newbie insert question
> 
> One only needs to specify the column names if and only if there are not
> values, in the correct order, for all of the columns in the table.
> 
> That is:
> Create Table foo (
>     aid      int    not null  auto_increment  primary key,
                                ^^^^^^^^^^^^^^
>     last     varchar(30),
>     first    varchar(30),
>     email    varchar(60)
> );
> 
> Right:
> Insert Into foo Values (0, '$lastname', '$firstname', '$email');
                          ^ 
> Insert Into foo (last, first, email) Values ('$lastname', '$firstname',
> '$email');
> 
> Wrong:
> Insert Into foo Values ('$lastname', '$firstname', '$email');
> 
> ..chris
> 
> ----- Original Message -----
> From: "Russell Miller" <[EMAIL PROTECTED]>
> To: "sjs" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Wednesday, October 03, 2001 7:53 PM
> Subject: Re: very newbie insert question
> 
> 
> I did not see the full schema so I can't give you a definite answer.
> However, your syntax is wrong:
> 
> INSERT INTO email_addresses (last_name, first_name, email_address) VALUES
> ("$lastname", "$firstname", "$email_address");
> 
> For each value you specify, you also have to specify a column name.
> 
> Did you set it up so the email_address field is the primary key?
> 
> HTH.
> 
> --Russell
> 
> ----- Original Message -----
> From: "sjs" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, October 03, 2001 7:51 PM
> Subject: very newbie insert question
> 
> 
> > This is my first script, so I am sorry it is so newbie-ish.
> > I think I have the correct script to open the connection, open the
> database
> > and the table. However, I cannot get the "insert into" to work. I have
> read
> > several online sources and books, all of which are slightly different. It
> is
> > not a parse error.  Can you help?
> >
> > Thanks
> > SJS
> >  Script as follows:
> >
> > <html>
> > <head><title>Adding Your Record to the Database</title></head>
> > <body>
> > <center>
> > <?php
> > if((!$lastName) || (!firstName) ||(!emailAddress))
> > {
> > echo "You have not entered all required informaton.<br> Please try again";
> > exit;
> > }
> > $lastName=addslashes($lastName);
> > $firstName=addslashes($firstName);
> > $email_address=addslashes($email_address);
> > @ $db=mysql_pconnect("", "","");
> > if (!$db)
> > {
> > echo "Couldn't connect to the database.<br>If problem persists, please
> > contact webmaster";
> > exit;
> > }
> > $db= mysql_select_db("emailDB");
> > if (!$db)
> > {
> > echo "Sorry. Could not retrieve correct database.<br> If problem persists,
> > please contact webmaster";
> > }
> > $sql = "INSERT INTO email_addresses VALUES ('$lastName', '$firstName',
> > '$email_address')";
> > $result = mysql_query($sql);
> > if (!$result)
> > {
> > echo "<p>Sorry.<br>Your address was not successfully added.<br>If problem
> > persists, please contact webmaster.";
> > }
> > else
> > {
> > echo "<p>DONE DEAL!";
> > }
> > ?>
> > </body>
> > </html>
> >
> >
> >
> > ---------------------------------------------------------------------
> > Before posting, please check:
> >    http://www.mysql.com/manual.php   (the manual)
> >    http://lists.mysql.com/           (the list archive)
> >
> > To request this thread, e-mail <[EMAIL PROTECTED]>
> > To unsubscribe, e-mail
> <[EMAIL PROTECTED]>
> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> 
> 
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
> 
> 
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
> 
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> 
> 
> 
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
> 
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> 

Sincerely,

William Mussatto, Senior Systems Engineer
CyberStrategies, Inc
ph. 909-920-9154 ext. 27


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to