MySQL won't insert
| From: | Tim Johnson | Date: | Thu, 26 Oct 2000 19:31:34 +0000 |
| Subject: | MySQL won't insert | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-22192@lists.php.net to get a copy of this message | ||
I am developing a PHP/MySQL sales database. When the completed html form
is submitted to MySQL, MySQL inserts a row that contains no information,
other than the timestamp and auto_increment info. When I echo out
mysql_error(), it reports there are no errors. I have successfully echoed
out all the values. When I echo out the query string and pass that
directly to MySQL, MySQL handles the insertion fine.
I would appreciate any insight on how to hunt down the problem.
Here's the query:
$query = "INSERT into Customers (DBAName, BillingName, BillingAddress1, ";
$query .= "BillingAddress2, BillingCity, BillingState, BillingZip,
BillingCountry, ";
$query .= "Phone1, Ext1, Phone2, Ext2, CellPhone, FAX, Email, WWW, ";
$query .= "PhysAddress1, PhysAddress2, PhysCity, PhysState, PhysZip,
PhysCountry, ";
$query .= "ContactNameFirst, ContactNameLast, ContactTitle, Notes, ";
$query .= "ContractTerms, ContractStart) ";
$query .= "VALUES ( '$DBAName', '$BillingName',
'$BillingAddress1', ";
$query .= "'$BillingAddress2', '$BillingCity', '$BillingState',
'$BillingZip', '$BillingCountry', ";
$query .= "'$Phone1', '$Ext1', '$Phone2', '$Ext2',
'$CellPhone', '$FAX',
'$Email', '$WWW', ";
$query .= "'$PhysAddress1', '$PhysAddress2', '$PhysCity',
'$PhysState',
'$PhysZip', '$PhysCountry', ";
$query .= "'$ContactNameFirst', '$ContactNameLast',
'$ContactTitle',
'$Notes', ";
$query .= "'$ContractTerms', '$ContractStart' )";
@mysql_query($query) or die(error("this is the problem area", mysql_error()));
If it reveals anything, here's the table structure:
CREATE TABLE Customers (
DateModified timestamp(14),
CustID int(11) DEFAULT '0' NOT NULL auto_increment,
DBAName varchar(50),
BillingName varchar(50),
BillingAddress1 varchar(255),
BillingAddress2 varchar(255),
BillingCity varchar(50),
BillingState varchar(25),
BillingZip varchar(12),
BillingCountry varchar(12),
Phone1 varchar(12),
Ext1 varchar(12),
Phone2 varchar(12),
Ext2 varchar(12),
CellPhone varchar(12),
FAX varchar(12),
Email varchar(50),
WWW varchar(50),
PhysAddress1 varchar(255),
PhysAddress2 varchar(255),
PhysCity varchar(50),
PhysState varchar(25),
PhysZip varchar(12),
PhysCountry varchar(12),
ContactNameFirst varchar(50),
ContactNameLast varchar(50),
ContactTitle varchar(50),
BusType varchar(25),
Rep char(2),
Notes text,
ContractTerms enum('none','4','8','13','26')
DEFAULT 'none' NOT NULL,
ContractStart date DEFAULT '0000-00-00',
ContractEnd date DEFAULT '0000-00-00',
PRIMARY KEY (CustID)
);
Tim Johnson, Editor
The Every Other Weekly
P.O. Box E, Bellingham WA 98227 USA
VOX: 360.676.1966 * FAX: 360.676.2625
E-mail: editor@eoweekly.com