Hello again all! Problem: Writing data gathered from an online form to a database on a server not at my location. The only info the server company can give me is Perl, not PHP.
Here is the table (table1):
id, mediumint(10),not null, primary key, auto_increment
date, date, '0000-00-00'
pagefrom, enum('A','B','C','D'),default=NULL
contact varchar(50), default=NULL
company varchar(255), default=NULL
address varchar(100)
address2, varchar(100), default=NULL
city, varchar(100)
state, char(2), default=NULL
zipcode, mediumint(10), default='0'
telephone, varchar(20), default=NULL
email, varchar(255)
ndtype, enum('A','B','C','D','E'), default=NULL
ndspecs, varchar(255), default=NULL
cpareqd, double, default='0'
cpcond, varchar(255), default=NULL
cpdamt, double, default='0'
cpdspecs, varchar(255), default=NULL
approved, enum('Y','N'), default='N'
Here is the code:
Code:
<?php
include "./common.inc";
if !$ndspecs {
$ndspecs = "NULL";
}
if !$cpareqd {
$cpareqd = "0";
}
if !$cpcond {
$cpcond = "NULL";
}
if !$cpdamt {
$cpdamt = "0";
}
if !$cpdspecs {
$cpdspecs = "NULL";
}
// Connect to db
$dbcnx = mysql_connect($dbhost,$dbusername,$dbuserpassword)
or die("Could not connect: " . mysql_error());
// Select db
mysql_select_db($default_dbname, $dbcnx);
// Input info to table
$query = "INSERT INTO table1 VALUES(NULL,curdate(),'$pagefrom','$contact','$company','$address','$address2','$city','$state','$zipcode','$telephone','$email','$ndtype','$ndspecs','$cpareqd','$cpcond','$cpdamt','$cpdspecs','$approved')";
$result = mysql_query($query);
if (!$result) {
die ('<p>Error performing insertion: ' . mysql_error() . '</p>');
}
//Close db
mysql_close($dbcnx);
?>
Doesn't work. I realize it's something stupid that I'm just not seeing. I have a lot of experience in this area, believe me.
I thought it might be the single quotes around the variables in the INSERT INTO statement, but Ch. 13, pg. 471 of the Beginning PHP4 book shows them.
Any ideas are welcome. Thanks!
HollyAnn
aka Scottiegirl
"I was put on Earth to accomplish a certain number of things. Right now I am so far behind, I will never die." - Calvin, Calvin and Hobbs