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 :)
Storing '," and ` in MYSQL
Started by Vswe, Nov 07 2009 01:31 PM
11 replies to this topic
#1
Posted 07 November 2009 - 01:31 PM
|
|
|
#2
Posted 07 November 2009 - 01:46 PM
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
PHP: base64_encode - Manual
PHP: base64_decode - Manual
#3
Posted 07 November 2009 - 01:48 PM
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.
#4
Posted 07 November 2009 - 01:49 PM
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
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
#5
Posted 07 November 2009 - 01:58 PM
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 :thumbup:
#6
Guest_Jordan_*
Posted 07 November 2009 - 02:01 PM
Guest_Jordan_*
I would just escape it, rather than encode/decode it. Use addslashes() or the mysql_real_escape_string() function.
#7
Posted 07 November 2009 - 02:03 PM
How should I use then? Only add backslashes to the string and then store it?
#8
Guest_Jordan_*
Posted 07 November 2009 - 02:19 PM
Guest_Jordan_*
If you use either of the functions I mentioned above, it will make this string:
look like this
When inserted into the database, it will become the original string again without the backslashes.
Be careful though, if the server has magic_quotes enabled you will double escape a string if you use those two functions.
what's going to happen "here"
look like this
what\'s going to happen \"here\"
When inserted into the database, it will become the original string again without the backslashes.
Be careful though, if the server has magic_quotes enabled you will double escape a string if you use those two functions.
#9
Posted 07 November 2009 - 02:20 PM
So I should do like this?
$texttostore = addslashes("what's going to happen \"here\"");
#10
Posted 07 November 2009 - 02:22 PM
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.
C:\\Program Files\Adobe
etc you get the idea.
#11
Guest_Jordan_*
Posted 07 November 2009 - 02:33 PM
Guest_Jordan_*
Vswe said:
So I should do like this?
$texttostore = addslashes("what's going to happen \"here\"");Perfect!
#12
Posted 07 November 2009 - 02:35 PM
OK, thanks both of you :thumbup:


Sign In
Create Account


Back to top










