RE: [PHP-DB] SQL Insert problem
| From: | Hutchins, Richard | Date: | Thu, 05 Aug 2004 14:25:44 +0000 |
| Subject: | RE: [PHP-DB] SQL Insert problem | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-35585@lists.php.net to get a copy of this message | ||
You're missing address2 in your list of values. This means that you have an
unmatching number of column names and values in your query and that'll make
the query bomb.
Rich
> -----Original Message-----
> From: Vincent Jordan [mailto:vjordan@smartparts.com]
> Sent: Thursday, August 05, 2004 10:25 AM
> To: php-db@lists.php.net
> Subject: [PHP-DB] SQL Insert problem
>
>
> 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.
>
>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <?php
>
> ini_set ('display_errors', 1);
>
> error_reporting (E_ALL & ~E_NOTICE);
>
> // Define
>
> $firstname = $_POST['firstname'];
>
>
>
> $lastname = $_POST['lastname'];
>
>
>
> $address = $_POST['address'];
>
>
>
> $address2 = $_POST['address2'];
>
>
>
> $city = $_POST['city'];
>
>
>
> $state = $_POST['state'];
>
>
>
> $zip = $_POST['zip'];
>
>
>
> $phone = $_POST['phone'];
>
>
>
> $email = $_POST['email'];
>
>
>
> $serial = $_POST['serial'];
>
>
>
> $product = $_POST['product'];
>
>
>
> $reason = $_POST['reason'];
>
>
>
> $gold = $_POST['gold_button_y'];
>
>
>
> $goldaccount = $_POST['goldaccount'];
>
>
>
> $rmanumber = $lastname{0}.date("ndyGi");
>
>
>
> $connect = mysql_connect("SERVER ", "USER", "PASSWORD") or die
> (mysql_error());
>
> $select = mysql_select_db ("spdata") or die (mysql_error());
>
> $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())";
>
> if (isset($_POST['submit'])) {
>
> $sql;
>
> }
>
> // Send and put in email message
>
> $htmlheader = "Content-Type: text/html; charset=us-ascii\n";
>
> $htmlheader .= "Content-Transfer-Encoding: 7bit";
>
> $header = $from; // set the from field in the header
>
> $header .= "\n"; // add a line feed
>
> $header .= "MIME-version: 1.0\n"; //add the mime-version header
>
> $header .= $htmlheader."\n";
>
> $from = "From: RMA Request <RMA@smartparts.com>";
>
> $message = "$firstname $lastname
>
> $address
>
> $address2
>
> $city
>
> $state
>
> $zip
>
> $phone
>
> $email
>
> $product
>
> $serial
>
> $gold
>
> $goldaccount
>
> $reason
>
> $rmanumber";
>
>
>
>
>
> // Send email to support
>
> mail("support@smartparts.com", "RMA Request", $message, $header);
>
> ?>
>
> <html xmlns="http://www.w3.org/1999/xhtml">
>
> <head>
>
> <title>Untitled Document</title>
>
> </head>
>
> <body>
>
> <p><strong>RMA Request Sent</strong></p>
>
> <p>Your RMA Number is <strong> <? echo $rmanumber ?> </strong>
> </p>
>
> <p>Please include a note within your package with your
> shipping address,
> phone number and discription of the problem.<br />When
> shipping Smart Parts
> reccomends insuring your package for the full replacment cost.
>
> We also advise purchasing tracking services if using the postal
> service.</p>
>
> <p><strong>Ship your return to: </strong></p>
>
> <p>Smart Parts, Inc<br />
>
> ATTN <? echo $rmanumber ?><br />
>
> Loyanhanna Business Complex<br />
>
> 100 Station St.<br />
>
> Loyalhanna Pa. 15661</p>
>
> <p><br />
>
> Please allow up to one week for package delivery.
>
> For status information please call 800-992-2147 and ask
> for the returns
> department.</p>
>
> <a href="#" onClick="window.print();">Click Here to print
> this page</a><br
> />
>
> <a href="form.htm">Click here to return to RMA Request form</a>
>
> </body>
>
> </html>
>
>
>
>