Re: [PHP-DB] SQL Insert problem (SOLVED), Thanks!
Thank you all for the help. I can't believe I forgot something so simple yet crucial. Thanks again for all the help. Vinny > -Original Message- > From: John W. Holmes [mailto:[EMAIL PROTECTED] > Sent: Thursday, August 05, 2004 11:04 AM > To: Vincent Jordan; [EMAIL PROTECTED] > Subject: [SPAM] Re: [PHP-DB] SQL Insert problem > > From: "Vincent Jordan" <[EMAIL PROTECTED]> > > > > > $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())"; > > Uhhh. where's mysql_query()??? > > $sql = "INSERT ..."; > > $result = mysql_query($sql) or die(mysql_error()); > > ---John Holmes... > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] SQL Insert problem
1. echo your $sql to make certain it's as sound as you think. 2. i don't see execution of the query: mysql_query( $sql) - you'll have to put the die() & error after this function. Hth - mthompson At 12:05 PM 8/5/2004, Vincent Jordan wrote: I have inserted '$address2', correctly in the row however it is still not putting the data in the table. I am not getting an error but I do believe I have correct syntax set to display problems. > -Original Message- > From: Hutchins, Richard [mailto:[EMAIL PROTECTED] > Sent: Thursday, August 05, 2004 10:26 AM > To: [EMAIL PROTECTED] > Subject: RE: [PHP-DB] SQL Insert problem > > 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:[EMAIL PROTECTED] > > Sent: Thursday, August 05, 2004 10:25 AM > > To: [EMAIL PROTECTED] > > 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. > > > > > > > > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> > > > > > > > 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 <[EMAIL PROTECTED]>"; > > > > $message = "$firstname $lastname > > > > $address > > > > $address2 > > > > $city > > > > $state > > > > $zip > > > > $phone > > > > $email > > > > $product > > > > $serial > > > > $gold > > > > $goldaccount > > > > $reason > > > > $rmanumber"; > > > > > > > > > > > > // Send email to support > > > > mail("[EMAIL PROTECTED]", "RMA Request", $message, $header); > > > > ?> > > > > http://www.w3.org/1999/xhtml";> > > > > > > > > Untitled Document > > > > > > > > > > > > RMA Request Sent > > > > Your RMA Number is > > > > Please include a note within your package with your > > shipping address, > > phone number and discription of the problem.When > > shipping Smart Parts > > reccomends insuring your package for the full replacment cost. > > > > We also advise purchasing tracking services if using the postal > > service. > > > > Ship your return to: > > > > Smart Parts, Inc > > > > ATTN > > > > Loyanhanna Business Complex > > > > 100 Station St. > > > > Loyalhanna Pa. 15661 > > > > > > > > Please allow up to one week for package delivery. > > > > For status information please call 800-992-2147 and ask > > for the returns > > department. > > > > Click Here to print > > this page > /> > > > > Click here to return to RMA Request form > > > > > > > > > > > > > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] SQL Insert problem
Try echoing out your query to the browser window before you send it to the database. A simple echo $sql should suffice. Then you can see what's actually being sent in the query string to the database. Thar may show you exactly what's going wrong. If your query string looks right, then the error lies elsewhere. Was your error reporting logic reporting that you had a mismatched number of columns and arguments before? If not, then your error reporting logic is probably not doing what you expect it to. Rich > -Original Message- > From: Vincent Jordan [mailto:[EMAIL PROTECTED] > Sent: Thursday, August 05, 2004 11:06 AM > To: [EMAIL PROTECTED] > Subject: RE: [PHP-DB] SQL Insert problem > > > I have inserted '$address2', correctly in the row however it > is still not > putting the data in the table. > > I am not getting an error but I do believe I have correct > syntax set to > display problems. > > > -Original Message- > > From: Hutchins, Richard [mailto:[EMAIL PROTECTED] > > Sent: Thursday, August 05, 2004 10:26 AM > > To: [EMAIL PROTECTED] > > Subject: RE: [PHP-DB] SQL Insert problem > > > > 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:[EMAIL PROTECTED] > > > Sent: Thursday, August 05, 2004 10:25 AM > > > To: [EMAIL PROTECTED] > > > 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. > > > > > > > > > > > > > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> > > > > > > > > > > > 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&qu
Re: [PHP-DB] SQL Insert problem
From: "Vincent Jordan" <[EMAIL PROTECTED]> > > > $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())"; Uhhh. where's mysql_query()??? $sql = "INSERT ..."; $result = mysql_query($sql) or die(mysql_error()); ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] SQL Insert problem
"John W. Holmes" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > From: "Vincent Jordan" <[EMAIL PROTECTED]> > > > 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 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] SQL Insert problem
I have inserted '$address2', correctly in the row however it is still not putting the data in the table. I am not getting an error but I do believe I have correct syntax set to display problems. > -Original Message- > From: Hutchins, Richard [mailto:[EMAIL PROTECTED] > Sent: Thursday, August 05, 2004 10:26 AM > To: [EMAIL PROTECTED] > Subject: RE: [PHP-DB] SQL Insert problem > > 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:[EMAIL PROTECTED] > > Sent: Thursday, August 05, 2004 10:25 AM > > To: [EMAIL PROTECTED] > > 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. > > > > > > > > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> > > > > > > > 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 <[EMAIL PROTECTED]>"; > > > > $message = "$firstname $lastname > > > > $address > > > > $address2 > > > > $city > > > > $state > > > > $zip > > > > $phone > > > > $email > > > > $product > > > > $serial > > > > $gold > > > > $goldaccount > > > > $reason > > > > $rmanumber"; > > > > > > > > > > > > // Send email to support > > > > mail("[EMAIL PROTECTED]", "RMA Request", $message, $header); > > > > ?> > > > > http://www.w3.org/1999/xhtml";> > > > > > > > > Untitled Document > > > > > > > > > > > > RMA Request Sent > > > > Your RMA Number is > > > > Please include a note within your package with your > > shipping address, > > phone number and discription of the problem.When > > shipping Smart Parts > > reccomends insuring your package for the full replacment cost. > > > > We also advise purchasing tracking services if using the postal > > service. > > > > Ship your return to: > > > > Smart Parts, Inc > > > > ATTN > > > > Loyanhanna Business Complex > > > > 100 Station St. > > > > Loyalhanna Pa. 15661 > > > > > > > > Please allow up to one week for package delivery. > > > > For status information please call 800-992-2147 and ask > > for the returns > > department. > > > > Click Here to print > > this page > /> > > > > Click here to return to RMA Request form > > > > > > > > > > > > > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] SQL Insert problem
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:[EMAIL PROTECTED] > Sent: Thursday, August 05, 2004 10:25 AM > To: [EMAIL PROTECTED] > 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. > > > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> > > > 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 <[EMAIL PROTECTED]>"; > > $message = "$firstname $lastname > > $address > > $address2 > > $city > > $state > > $zip > > $phone > > $email > > $product > > $serial > > $gold > > $goldaccount > > $reason > > $rmanumber"; > > > > > > // Send email to support > > mail("[EMAIL PROTECTED]", "RMA Request", $message, $header); > > ?> > > http://www.w3.org/1999/xhtml";> > > > > Untitled Document > > > > > > RMA Request Sent > > Your RMA Number is > > Please include a note within your package with your > shipping address, > phone number and discription of the problem.When > shipping Smart Parts > reccomends insuring your package for the full replacment cost. > > We also advise purchasing tracking services if using the postal > service. > > Ship your return to: > > Smart Parts, Inc > > ATTN > > Loyanhanna Business Complex > > 100 Station St. > > Loyalhanna Pa. 15661 > > > > Please allow up to one week for package delivery. > > For status information please call 800-992-2147 and ask > for the returns > department. > > Click Here to print > this page /> > > Click here to return to RMA Request form > > > > > > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php