Hi,
My first post so I hope I can explain this correctly...
I have a table that looks like this ...
CREATE TABLE IF NOT EXISTS `kb_services` (
`serv_id` mediumint(7) NOT NULL AUTO_INCREMENT,
`serv_text` varchar(100) NOT NULL,
`serv_cost` decimal(5,2) NOT NULL,
`serv_freq` char(1) NOT NULL,
`serv_desc` longtext NOT NULL,
`serv_type` char(1) NOT NULL,
PRIMARY KEY (`serv_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=26 ;
I am updating/inserting to this table from the results of a form.
My insert code looks like this ..
$db = @mysql_connect("localhost","xxxxx","xxxxx") or header("Location: xxxt.php");
mysql_select_db("xxxx",$db) or header("Location: xxx.php");
$a = addslashes(trim($_POST['serv_text']));
$b = addslashes(trim($_POST['serv_freq']));
$c = addslashes(trim($_POST['serv_cost']));
$d = addslashes(trim($_POST['serv_desc']));
mysql_query($sql = "INSERT INTO kb_services (serv_text,serv_freq,serv_cost,serv_desc,serv_type) VALUES ('$a','$b','$c','$d','D')");
this inserts a record but all the variables are blank except for serv_type. I echoed the $sql immediately after the insert and it looks like this
INSERT INTO kb_services (serv_text,serv_freq,serv_cost,serv_desc,serv_type) VALUES ('Test Text','O','19.99','Test Description','D')
If I go directly into the Db (using phpmyadmin) and paste the echoed code into a sql statement then the record is inserted with all values recorded correctly.
Any ideas please?
Many thanks
John G