Re: very newbie insert question

2001-10-04 Thread William R. Mussatto

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  intnot null  auto_increment  primary key,
^^
> last varchar(30),
> firstvarchar(30),
> emailvarchar(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:
> >
> > 
> > Adding Your Record to the Database
> > 
> > 
> >  > if((!$lastName) || (!firstName) ||(!emailAddress))
> > {
> > echo "You have not entered all required informaton. 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.If problem persists, please
> > contact webmaster";
> > exit;
> > }
> > $db= mysql_select_db("emailDB");
> > if (!$db)
> > {
> > echo "Sorry. Could not retrieve correct database. If problem persists,
> > please contact webmaster";
> > }
> > $sql = "INSERT INTO email_addresses VALUES ('$lastName', '$firstName',
> > '$email_address')";
> > $result = mysql_query($sql);
> > if (!$result)
> > {
> > echo "Sorry.Your address was not successfully added.If problem
> > persists, please contact webmaster.";
> > }
> > else
> > {
> > echo "DONE DEAL!";
> > }
> > ?>
> > 
> > 
> >
> >
> >
> > -
> > 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]>

RE: very newbie insert question

2001-10-04 Thread Jonathan Hilgeman

I always use 

INSERT INTO table SET field1='value', field2='value', etc...

If I don't specify fields like an auto-incrementing number, it is filled in
automatically.

- Jonathan

-Original Message-
From: sjs [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 03, 2001 5:51 PM
To: [EMAIL PROTECTED]
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:


Adding Your Record to the Database


 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.If problem persists, please
contact webmaster";
exit;
}
$db= mysql_select_db("emailDB");
if (!$db)
{
echo "Sorry. Could not retrieve correct database. If problem persists,
please contact webmaster";
}
$sql = "INSERT INTO email_addresses VALUES ('$lastName', '$firstName',
'$email_address')";
$result = mysql_query($sql);
if (!$result)
{
echo "Sorry.Your address was not successfully added.If problem
persists, please contact webmaster.";
}
else
{
echo "DONE DEAL!";
}
?>





-
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




Re: very newbie insert question

2001-10-03 Thread Chris Johnson

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  intnot nullprimary key,
last varchar(30),
firstvarchar(30),
emailvarchar(60)
);

Right:
Insert Into foo Values (1, '$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:
>
> 
> Adding Your Record to the Database
> 
> 
>  if((!$lastName) || (!firstName) ||(!emailAddress))
> {
> echo "You have not entered all required informaton. 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.If problem persists, please
> contact webmaster";
> exit;
> }
> $db= mysql_select_db("emailDB");
> if (!$db)
> {
> echo "Sorry. Could not retrieve correct database. If problem persists,
> please contact webmaster";
> }
> $sql = "INSERT INTO email_addresses VALUES ('$lastName', '$firstName',
> '$email_address')";
> $result = mysql_query($sql);
> if (!$result)
> {
> echo "Sorry.Your address was not successfully added.If problem
> persists, please contact webmaster.";
> }
> else
> {
> echo "DONE DEAL!";
> }
> ?>
> 
> 
>
>
>
> -
> 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




Re: very newbie insert question

2001-10-03 Thread Russell Miller

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:
>
> 
> Adding Your Record to the Database
> 
> 
>  if((!$lastName) || (!firstName) ||(!emailAddress))
> {
> echo "You have not entered all required informaton. 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.If problem persists, please
> contact webmaster";
> exit;
> }
> $db= mysql_select_db("emailDB");
> if (!$db)
> {
> echo "Sorry. Could not retrieve correct database. If problem persists,
> please contact webmaster";
> }
> $sql = "INSERT INTO email_addresses VALUES ('$lastName', '$firstName',
> '$email_address')";
> $result = mysql_query($sql);
> if (!$result)
> {
> echo "Sorry.Your address was not successfully added.If problem
> persists, please contact webmaster.";
> }
> else
> {
> echo "DONE DEAL!";
> }
> ?>
> 
> 
>
>
>
> -
> 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




very newbie insert question

2001-10-03 Thread sjs

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:


Adding Your Record to the Database


 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.If problem persists, please
contact webmaster";
exit;
}
$db= mysql_select_db("emailDB");
if (!$db)
{
echo "Sorry. Could not retrieve correct database. If problem persists,
please contact webmaster";
}
$sql = "INSERT INTO email_addresses VALUES ('$lastName', '$firstName',
'$email_address')";
$result = mysql_query($sql);
if (!$result)
{
echo "Sorry.Your address was not successfully added.If problem
persists, please contact webmaster.";
}
else
{
echo "DONE DEAL!";
}
?>





-
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