Is there a php function to convert text to decimal ncr?

by manhal
5 replies
Is there a way to convert input texts to its decimal ncr in php?
I am currently using the form method (<form> & <input>) to send text information to a php file.

But I would like to send these texts converted to ncr decimal.
For example, when I type "abc" in text input, I want it to be sent to php as
& #97 ;&# 98;&# 99;.

The reason because post returns error when text contains quotas, question marks, smile faces ... etc.

Thanks
#convert #decimal #function #ncr #php #text
  • Profile picture of the author xrvel
    Try not to convert it to decimal-code, lets try to fix the error
    What kind of error that you get?
    {{ DiscussionBoard.errors[3216173].message }}
  • Profile picture of the author EvaBrown
    No, you use php to convert the characters. HTML isn't programming, it's markup. (You could use Javascript, but why bother? It's trivial in php.
    {{ DiscussionBoard.errors[3216342].message }}
  • Profile picture of the author n7 Studios
    Originally Posted by manhal View Post

    Is there a way to convert input texts to its decimal ncr in php?
    I am currently using the form method (<form> & <input>) to send text information to a php file.

    But I would like to send these texts converted to ncr decimal.
    For example, when I type "abc" in text input, I want it to be sent to php as
    & #97 ;&# 98;&# 99;.

    The reason because post returns error when text contains quotas, question marks, smile faces ... etc.

    Thanks
    PHP: htmlentities - Manual will convert a string into a HTML-entity based string (i.e. with quotes as & quot; etc).

    This will then let you store the string into your database.
    {{ DiscussionBoard.errors[3216717].message }}
  • Profile picture of the author KirkMcD
    Originally Posted by manhal View Post

    The reason because post returns error when text contains quotas, question marks, smile faces ... etc.
    POST doesn't care what's in the string. The problem is whatever you do to process the data later.
    If you are inserting the data into a database, you should escape the string before trying to insert it.

    If you are programming in PHP:
    For MySQL use mysqli_real_escape_string (mysql_escape_string in PHP 4.X)
    Otherwise use addslashes

    For other languages, look up how to escape a string.
    {{ DiscussionBoard.errors[3217655].message }}
  • Profile picture of the author stma
    and since we don't have all the details of what you are trying to do to actually answer your question you need to look into iconv.

    East to change from one encoding to another encoding type with it.
    {{ DiscussionBoard.errors[3218841].message }}

Trending Topics