RE: SQL Insert problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



All you have done here is just assigned the query string to a variable. This alone does absolutely nothing as far as the db is concerned. You need to execute the query against the db for it to have an effect. The mysql_query() function is used for all queries, not just selects.


$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')";

$result = mysql_query ($sql, $connect) or die (mysql_error($connect))";


-----Original Message-----
From:	Vincent Jordan [mailto:vjordan@xxxxxxxxxxxxxx]
Sent:	Thu 8/5/2004 7:24 AM
To:	php-db@xxxxxxxxxxxxx
Cc:	
Subject:	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@xxxxxxxxxxxxxx>";

$message = "$firstname $lastname

$address

$address2

$city

$state

$zip

$phone

$email

$product

$serial

$gold

$goldaccount

$reason

$rmanumber";

 

 

// Send email to support

mail("support@xxxxxxxxxxxxxx", "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>

 





[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux