Re: SQL Insert problem
| From: | Torsten Roehr | Date: | Thu, 05 Aug 2004 15:03:24 +0000 |
| Subject: | Re: SQL Insert problem | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-35588@lists.php.net to get a copy of this message | ||
"John W. Holmes" <holmes072000@charter.net> wrote in message
news:012d01c47af8$7250ea00$e95a089b@GORDWKTB1S4A002...
> From: "Vincent Jordan" <vjordan@smartparts.com>
>
> > Im having a problem inserting data. Ive looked over this again and again
> and
> > can not find what ive missed. Everything else works besides the db
insert.
>
> It would have helped if you told us the error you got was "column count
does
> not match value count" or something similar...
>
> > $sql = "INSERT INTO rmarequest (firstname, lastname, address, address2,
> > city, state, zip, phone, email, serial, product, reason,
rmanumber)VALUES
> > ('$firstname', '$lastname', '$address', '$city',
> > '$state', '$zip',
> '$phone',
> > '$email', '$serial', '$product', '$reason',
> > '$rmanumber') or die
> > (mysql_error())";
>
> You list 13 columns to insert into but only give 12 values.
>
Vincent, you can use the alternative INSERT syntax to avoid this problem in
the future:
INSERT INTO table SET
column1 = '$value1',
column2 = '$value2',
column3 = '$value3',
...
Regards, Torsten Roehr