Re: MySQL won't insert

From: Date: Fri, 27 Oct 2000 14:33:35 +0000
Subject: Re: MySQL won't insert
Groups: php.general 
Request: Send a blank email to php-general+get-22336@lists.php.net to get a copy of this message
That looks fine. Have you tried to echo $query before the mysql_query statement? Also, you might want to check the configuration settings of track_vars and register_globals with phpinfo() to see if both are on. If track_vars is on, but register_globals is off use $HTTP_POST_VARS["var_name"] to get the values of the post vars ($HTTP_GET_VARS["var"] for get method). >>> Tim Johnson <tim@eoweekly.com> 10/26 3:31 PM >>> 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

« previous php.general (#22336) next »