|
-
Oct 15th, 2006, 11:04 PM
#1
Thread Starter
WiggleWiggle
Quotes in MySQL
How come when i put quotes into MySQL it displays with backslashes?
My usual boring signature: Something
-
Oct 16th, 2006, 12:08 AM
#2
Re: Quotes in MySQL
uhh. put them in how?
it won't add backslashes to anything unless you do it yourself using some function.
-
Oct 16th, 2006, 02:00 AM
#3
Re: Quotes in MySQL
Yes it will, if you use the magic_quotes misfeature. (It's enabled by default on most PHP installations.)
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 16th, 2006, 07:30 PM
#4
Thread Starter
WiggleWiggle
Re: Quotes in MySQL
 Originally Posted by CornedBee
Yes it will, if you use the magic_quotes misfeature. (It's enabled by default on most PHP installations.)
how do you reverse this mis-feature?
My usual boring signature: Something
-
Oct 16th, 2006, 08:31 PM
#5
Junior Member
Re: Quotes in MySQL
You can change it in php.ini
It looks something like this:
Code:
; Magic quotes for incoming GET/POST/Cookie data.
magic_quotes_gpc = On
; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc.
magic_quotes_runtime = Off
; Use Sybase-style magic quotes (escape ' with '' instead of \').
magic_quotes_sybase = Off
or you can use the stripslashes function.
Break out from your mental box.
I found better company. Iced chocolate with coffee jelly, anyone?
-
Oct 16th, 2006, 09:25 PM
#6
Thread Starter
WiggleWiggle
Re: Quotes in MySQL
where is the php.ini located?
My usual boring signature: Something
-
Oct 16th, 2006, 09:43 PM
#7
-
Oct 16th, 2006, 09:44 PM
#8
Re: Quotes in MySQL
if your website is using a shared web hosting plan, you can probably -not- change the php.ini. you can try putting a ticket in to petition the option being changed, but other than that you are probably out of luck in that department. i did some looking around in the php functions, but couldn't find anything to disable magic_quotes_gpc.
however, by default, on windows systems the ini file is installed to C:/Windows/
-
Oct 16th, 2006, 09:52 PM
#9
Thread Starter
WiggleWiggle
Re: Quotes in MySQL
i am using cpanel and it says that i have "FreeBSD". and my hosting company sucks so they will not want to help me. lol. I will try to see if they will change it for me. Yeah, i am on shared hosting -unfortunanly-
My usual boring signature: Something
-
Oct 16th, 2006, 09:57 PM
#10
Re: Quotes in MySQL
FreeBSD is a Unix based OS, but since you are on a shared hosting plan I highly doubt you can run any type of Unix command to find the files. the most you can do is send in a ticket and ask if they can change it (although I doubt they would, because with most shared webhosting plans, multiple accounts are using the same ini file on a given server, and a change like that could possibly break someone else's website.. might turn into some kind of vote thing for the accounts on that server, though..), otherwise you'll just have to remove the slashes yourself through functions.
-
Oct 17th, 2006, 06:55 AM
#11
Re: Quotes in MySQL
Here's how to reverse the effect of magic_quotes: include this snippet at the top of every PHP file:
Code:
if(get_magic_quotes_gpc()) {
foreach($_GET as $k => $v) {
$_GET[$k] = stripslashes($v);
}
foreach($_POST as $k => $v) {
$_POST[$k] = stripslashes($v);
}
foreach($_COOKIE as $k => $v) {
$_COOKIE[$k] = stripslashes($v);
}
}
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 17th, 2006, 09:18 AM
#12
Re: Quotes in MySQL
 Originally Posted by CornedBee
Here's how to reverse the effect of magic_quotes: include this snippet at the top of every PHP file:
Code:
if(get_magic_quotes_gpc()) {
foreach($_GET as $k => $v) {
$_GET[$k] = stripslashes($v);
}
foreach($_POST as $k => $v) {
$_POST[$k] = stripslashes($v);
}
foreach($_COOKIE as $k => $v) {
$_COOKIE[$k] = stripslashes($v);
}
}
Unfortunately that only does a shallow reverse and magic quotes is a deep operation, so you will need something more like this:
PHP Code:
if (get_magic_quotes_gpc()) {
array_walk_recursive($_GET, $rv_func = create_function('$n', 'stripslashes($n);'));
array_walk_recursive($_POST, $rv_func);
array_walk_recursive($_COOKIE, $rv_func);
}
There are also some other things that are affected by it, can't remember them off the top of my head right now.
-
Oct 17th, 2006, 11:29 AM
#13
Re: Quotes in MySQL
Didn't know it was recursive, though of course that makes sense. Good call.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|