# Thread: special characters in PHP script...

1. Registered User
Join Date
Jan 2003
Location
DE
Posts
27

## special characters in PHP script...

hi everybody,

has any of you an idea, how to print double backslashes in a script?

the idea is to generate a mysql query that looks for some windows unc path (on a db...).
so i need to look for a string like \\serverunc\path1\path2 and so on within the query.

now when i hand it a \\ it should recognize it as a single backslash, right!?
so \\\\ should generate a simple \\, shouldn't it?
but that won't work for some reason.
i know that there is an escaping difference between the utf-sets but when i call a query, i need to use single quotes ('').

so what can i do?

EDIT:
identified the question as mysql 'LIKE' operator problem...
the LIKE statement seems to not accept such syntax. i'll be looking for the correct syntax.
Last edited by MuSQLe; 06-30-2004 at 05:23 AM.

2. Registered User
Join Date
Jan 2003
Location
DE
Posts
27

## SOLUTION

i found out, that not only the php-parser uses c-syntax for escaping special characters but also does mysql.
the mysql parser also cuts the escape characters which in the end doubles the number of backslashes to use.

this makes it for the above problem 16! backslashes for the LIKE comparison to work.
so mysql regards \\\\ as a single \ and php also demands \\ for \ to print.
first of all php cuts \\\\\\\\\\\\\\\\ in half => \\\\\\\\ and mysql (which uses \\\\ for \) makes it \\ in the end...
[so the hierarchy of commands executed is important to know for this point determines the number of slashes to use...]

STRANGE... but problem solved!
(cost me almost a day!!!)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•