Ok this is a new one for me. Basically I have a table articles:
id: int auto increment title: varchar(200) description: varchar(1000) ctext: longtext chtml: longtext
Now I do an insert into this table with mysql_query:
INSERT INTO articles (title, description, ctext, chtml) VALUES ('$title', '$description', '$text', '$html')
All values have been passed through mysql_escape_string().
The text and html here are roughly 50k in size (so I can’t really post the fully query here).
Now, here’s the problem: the query works. A new row is inserted. However the ctext and chtml columns are empty. This is MySQL 5.0.51a and PHP 5.2.8. No errors are raised of any kind as far as I can tell.
Now I dumped the query out to a file in /tmp and ran it with:
mysql -u username -p dbname < /tmp/query
Same thing.
I copy the query into Navicat and it… works.
So what on earth is going on?
Some random thoughts:
mysql_escape_string?Addition: MySQL connections defaults to latin1, you need to use something like
mysql_query('SET NAMES 'utf8'')to transfer unicode characters.