How can I store '," and ` in MYSQL using PHP? And do I need to do anything special then when receiving the values from the databas?
Thanks![]()
Your trying to store it inside of a row? You probably can just escape it. Usually when I store a bunch of funky characters I would encode it, then decode when I pull it out.
PHP: base64_encode - Manual
PHP: base64_decode - Manual
So I should do that on the whole string then? What I'm trying to make sort of a chat and I want to allow those chars too.
Yea, id store the whole thing encrypted.
If you want to be able to sort by the string you might trying using aes which I mysql supports
MySQL :: MySQL 5.1 Reference Manual :: 11.11.2 Encryption and Compression Functions
There's no need for that, the only thing I needs in order is the messages' ID so it's fine. Thanks for the help![]()
I would just escape it, rather than encode/decode it. Use addslashes() or the mysql_real_escape_string() function.
How should I use then? Only add backslashes to the string and then store it?
If you use either of the functions I mentioned above, it will make this string:
look like thisCode:what's going to happen "here"
When inserted into the database, it will become the original string again without the backslashes.Code:what\'s going to happen \"here\"
Be careful though, if the server has magic_quotes enabled you will double escape a string if you use those two functions.
So I should do like this?
Code:$texttostore = addslashes("what's going to happen \"here\"");
Yes but when removing slashes it removes all of them. If you intentionally had them say for a local address
C:\\Program Files\Adobe
etc you get the idea.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks