Results 1 to 6 of 6

Thread: Can't save data if there is a : ' (quote) in the input field

  1. #1
    Sencha User
    Join Date
    Aug 2009
    Posts
    113

    Red face Can't save data if there is a : ' (quote) in the input field

    Hello,

    If I write a ' in my input, I can't save data (nothing happens), however I use json_encode and decode.

    If someone have an idea ?

    Laurent

  2. #2
    Sencha User VinylFox's Avatar
    Join Date
    Mar 2007
    Location
    Baltimore, MD
    Posts
    1,501

    Default

    You will need to provide more information for us to help you. A code sample can do wonders.

  3. #3
    Sencha User
    Join Date
    Jan 2008
    Location
    Maryville, IL, US
    Posts
    288

    Default

    This merely sounds like a SQL issue to me (as an apostrophe is a special character). You should be able to escape it in whatever manner your database calls for (Oracle would be a double apostrophe, MySQL uses slash apostrophe, etc.)

  4. #4
    Sencha User
    Join Date
    Aug 2009
    Posts
    113

    Default

    Exactly, thank's Httpdotcom,

    I modified my php script with that, and it's good now :

    Code:
                $query="update $table set ";
                foreach($data as $cle=>$valeur){
                    $query.="$cle='".addslashes($valeur)."', ";
                }
                $query=substr($query, 0, -2); // Supprime la dernire virgule       
                $query.=" where $idkey='$id' ";

  5. #5
    Sencha User VinylFox's Avatar
    Join Date
    Mar 2007
    Location
    Baltimore, MD
    Posts
    1,501

    Default

    You should really use the database specific escape functions available, such as 'mysqli_real_escape_string' or 'pg_escape_string', etc.

  6. #6
    Sencha User
    Join Date
    Jul 2009
    Posts
    32

    Default

    ...or replace a single ' with 2x '

Posting Permissions

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