On 13 Mar 2003, at 14:59, lauren wrote:

> if u try to execute a query such as:
> 
> insert into foo (id,textfield) values (54,'\\fred\\')
> 
> the query fails
> 
> if i add a space after the last \\ it works
> this is a real pain personally cos we use a lot of that stuff :(

You'll have to show us exactly how you're getting the query to MySQL. 
Are you using PHP? Perl? C?  Regardless, I suspect that by the time 
the SQL gets to MySQL you don't have as many backslashes as you think 
you do.  Constructing strings that have contain backslashes, 
especially multiple backslashes, and passing them around can be 
tricky.  If you're doing this in PHP:

  $sql = "INSERT INTO foo (id, text_field) VALUES (54, '\\fred\\')";

then the string doesn't actually contain double backslashes, only 
single ones, so it'll be invalid if you pass it to MySQL.  You'll 
need quadruple backslashes in your PHP to end up with double 
backslashes in your SQL.  (And things get even worse if you're using 
LIKE, which involves yet another level of escaping.)

If your backslash-containing strings are file paths, you might 
consider avoiding the complication and using forward slashes instead. 
They work fine on Windows in most contexts.

-- 
Keith C. Ivey <[EMAIL PROTECTED]>
Tobacco Documents Online
http://tobaccodocuments.org
Phone 202-667-6653

---------------------------------------------------------------------
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

Reply via email to