VVM Ravikumar Sarma Chengalvala writes:
> Sinisa,
> 1.
> Thanks for the mail.
> 2.
> I observed that mysql_escape_string()soes not work
> either.If I want to store a file name with back
> slashes,I feel mysql_escape_string() should introduce
> the additional backslash required .But it does not do
> so.It is just copying from source string to
> destination string.
> 3.
> Because of this I am unable to store the escape string
> into the database.By the way can you send me the exact
> syntax for mysql_escape_string() so that I can check
> it up to further confirm that I am not missing out on
> any thing.
> 4.
> mysql_escape_string() does not complain but I feel it
> is not doing what it is supposed to do.
> 
> Regards,
> Ravi  


Hi!

mysql_escape_string() will escape all chars properly. I use it
everyday in many programs without a single glitch.

You probably did not pass a correct parameters, as mysql_escape_string
will escape them properly. Here is an excerpt from the function
itself:

    switch (*from) {
    case 0:                             /* Must be escaped for 'mysql' */
      *to++= '\\';
      *to++= '0';
      break;
    case '\n':                          /* Must be escaped for logs */
      *to++= '\\';
      *to++= 'n';
      break;
    case '\r':
      *to++= '\\';
      *to++= 'r';
      break;
    case '\\':
      *to++= '\\';
      *to++= '\\';
      break;
    case '\'':
      *to++= '\\';
      *to++= '\'';
      break;
    case '"':                           /* Better safe than sorry */
      *to++= '\\';
      *to++= '"';
      break;
    case '\032':                        /* This gives problems on Win32 */
      *to++= '\\';
      *to++= 'Z';
      break;
    default:
      *to++= *from;


As you can see '\\' is escaped too...


Regards,

Sinisa

      ____  __     _____   _____  ___     ==  MySQL AB
     /*/\*\/\*\   /*/ \*\ /*/ \*\ |*|     Sinisa Milivojevic
    /*/ /*/ /*/   \*\_   |*|   |*||*|     mailto:[EMAIL PROTECTED]
   /*/ /*/ /*/\*\/*/  \*\|*|   |*||*|     Larnaca, Cyprus
  /*/     /*/  /*/\*\_/*/ \*\_/*/ |*|____
  ^^^^^^^^^^^^/*/^^^^^^^^^^^\*\^^^^^^^^^^^
             /*/             \*\                Developers Team

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