(The following was done in mysql_4.0 alpha) I am having difficulties with entering binary data from a c program. I have passed the string through mysql_real_escape_string. What I am seeing is that if the binary data contains an ascii 0, then mysql_real_escape_string, correctly, translates it to \0, but the data is still truncated in the database at that \0. In order to get the data in the database you need to "double escape" the null. You can reproduce the problem by running the following sql snippet using, mysql -D my_database -e "source myfile.sql" where myfile.sql contains, -- snip -- drop table if exists junk5; create table junk5 ( id int not null, primary key(id), s1 char(10) not null, i1 smallint not null ); insert junk5 values(1,'abc\0def\0gh', 2); insert junk5 values(2,'abc\\0def\\0gh', 3); insert junk5 values(3,'abc\\0def\0gh', 4); select * from junk5;
-- -- snip By running this snippet, you will see that you need to "double escape" the null to get it in the database. But mysql_real_escape_string doesn't do this. Is this a problem, or am I missing something. Many regards, Ian Collins. --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php