Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9

Thread: character

  1. #1
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts

    character

    I am retrieving data from the database and i noticed that one of the items has a " for inches in the word.When i display it in a table it displays perfectly but when i display it in a form field it only displays the characters before the ".
    I understand why this is happening but i am wondering is there a way of preventing it?

    thanks

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,503
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Try making it: "

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    addslashes() and stripslashes()
    Make sure magic_quote_gpc directive is not on.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #4
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts
    could it be anything to to with the text field because it works everywhere else?
    i tried adding and stripping slashes on the value for the textfield but it's still not working

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    I'm betting on it being an addslashes issue with magic_quotes_gpc()
    magic_quotes_gpc is on by default in the php.ini. You can set this at PHP_INI_ALL level (so, anywhere). It works by automatically adding slashes to input fields that have been say, posted by a form. So, in your database its written as
    Hello, I\'m Fou-Lu
    Though display wise, it will not have the escape.
    So, if you run addslashes prior to writting to a database, you have:
    Hello, I\\\'m Fou-Lu
    And only one set (\\) will be removed. Two solutions, don't addslashes to your db input (still use your mysql_real_escape_string though!), or disable the magic_quotes_gpc. I'd go for the magic quotes, this will make your script more portable for future usages.

    Oops, guess the code would help:
    PHP Code:
    ini_set('magic_quotes_gpc'0); 
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #6
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for your time.
    I tired that too but it didnt work.
    The word is something like "10" pizza" and the text box only displays "10".

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Sorry, I've been foolish.
    htmlspecialchars() will parse it for text input fields. I was thinking on a text area.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #8
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts
    perfect your a star! thanks

  • #9
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    No problem bunny
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  

    Posting Permissions

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