baffled_in_the_UK
-
Posts
4 -
Joined
-
Last visited
Never
Posts posted by baffled_in_the_UK
-
-
Thanks for replying.
No, I only have the one Db for this project. I could kind of understand if a record was not being written due to coding error/data problems but not being written with the variables not recorded, the sql statement is valid syntax and it works within phpmyadmin. I just cannot understand this.
(to answer the other question... I used $sql to make it simple to echo it).
-
Just a suggestion and assuming you have control over the page creation in your cms.
Create two files meta.htm and meta_noindex.htm
Put the relevant meta tag value into each
If page content is blank then include meta_noindex.htm else include meta.htm
Hope this is helpful?
-
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
Weird MySQL problem
in PHP Coding Help
Posted
Thanks Enthusiast.
It actually does work as a standalone script so I guess there is something strange going on within my actual page and yet the echoed $sql value looks fine!
I'll have another look. Thanks again.