473,403 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

where do the backslashes (\) come from?

Whenever I enter an apostrophe (') into a text box I receive \'. The
same behavior obtains with both get and post. Is there a php setting
which causes this (to me, at least) bizarre behavior? Or one to shut it off?

Jul 17 '05 #1
7 1816
"Robert Stearns" <rs**********@charter.net> wrote in message
news:10*************@corp.supernews.com...
Whenever I enter an apostrophe (') into a text box I receive \'. The
same behavior obtains with both get and post. Is there a php setting
which causes this (to me, at least) bizarre behavior? Or one to shut it off?


Set the magic_quotes_gpc directive in php.ini to Off. Or if you don't have
access to php.ini, check out the get_magic_quotes_gpc() function
(http://us2.php.net/get-magic-quotes-gpc).

- JP
Jul 17 '05 #2
I noticed that Message-ID: <10*************@corp.supernews.com> from
Robert Stearns contained the following:
Whenever I enter an apostrophe (') into a text box I receive \'. The
same behavior obtains with both get and post. Is there a php setting
which causes this (to me, at least) bizarre behavior? Or one to shut it off?


It's not bizarre. Apostrophes need to be escaped to prevent them being
seen as part of the script. If you were to turn magic quotes off, you'd
still have to use addslashes() to put them in.

Use stripslashes() to remove them.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #3
In article <mTFMc.164394$JR4.23280@attbi_s54>,
"kingofkolt" <je**********@comcast.net> writes:
"Robert Stearns" <rs**********@charter.net> wrote in message
news:10*************@corp.supernews.com...
Whenever I enter an apostrophe (') into a text box I receive \'. The
same behavior obtains with both get and post. Is there a php setting
which causes this (to me, at least) bizarre behavior? Or one to shut it

off?


Set the magic_quotes_gpc directive in php.ini to Off. Or if you don't have
access to php.ini, check out the get_magic_quotes_gpc() function
(http://us2.php.net/get-magic-quotes-gpc).


I'm no PHP "guru," but this strikes me as... questionable advice.
Wouldn't it be safer, and more secure, to use stripslashes() where
you know you don't want them?

--
Jim Seymour | PGP Public Key available at:
WARNING: The "From:" address | http://www.uk.pgp.net/pgpnet/pks-commands.html
is a spam trap. DON'T USE IT! |
Use: js******@LinxNet.com | http://jimsun.LinxNet.com
Jul 17 '05 #4
On Sun, 25 Jul 2004 16:06:41 -0000
js******@LinxNet.com (Jim Seymour) wrote:
In article <mTFMc.164394$JR4.23280@attbi_s54>,
"kingofkolt" <je**********@comcast.net> writes:
"Robert Stearns" <rs**********@charter.net> wrote in message
news:10*************@corp.supernews.com...
Whenever I enter an apostrophe (') into a text box I receive \'.

The> same behavior obtains with both get and post. Is there a php
setting> which causes this (to me, at least) bizarre behavior? Or one
to shut it
off?


Set the magic_quotes_gpc directive in php.ini to Off. Or if you
don't have access to php.ini, check out the get_magic_quotes_gpc()
function(http://us2.php.net/get-magic-quotes-gpc).


I'm no PHP "guru," but this strikes me as... questionable advice.
Wouldn't it be safer, and more secure, to use stripslashes() where
you know you don't want them?


Yeah... That would probably be the safest way to deal with it...
--
Anders K. Madsen --- http://lillesvin.linux.dk

"There are 10 types of people in the world.
Those who understand binary - and those who don't."

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBA9/flNHJe/JASHcRAu+rAJ9rI7dqOBT1iTBS4NEQarrTPc4lUwCbBMns
SKq+wuLLxfVqb92iza2N7S4=
=LdRr
-----END PGP SIGNATURE-----

Jul 17 '05 #5
"Jim Seymour" <js******@LinxNet.com> wrote in message
news:10*************@corp.supernews.com...
In article <mTFMc.164394$JR4.23280@attbi_s54>,
"kingofkolt" <je**********@comcast.net> writes:
"Robert Stearns" <rs**********@charter.net> wrote in message
news:10*************@corp.supernews.com...
Whenever I enter an apostrophe (') into a text box I receive \'. The
same behavior obtains with both get and post. Is there a php setting
which causes this (to me, at least) bizarre behavior? Or one to shut it off?


Set the magic_quotes_gpc directive in php.ini to Off. Or if you don't have access to php.ini, check out the get_magic_quotes_gpc() function
(http://us2.php.net/get-magic-quotes-gpc).


I'm no PHP "guru," but this strikes me as... questionable advice.
Wouldn't it be safer, and more secure, to use stripslashes() where
you know you don't want them?

--
Jim Seymour | PGP Public Key available at:
WARNING: The "From:" address |

http://www.uk.pgp.net/pgpnet/pks-commands.html is a spam trap. DON'T USE IT! |
Use: js******@LinxNet.com | http://jimsun.LinxNet.com


Well, I guess I was supposing that Robert's situation was this: a user
enters text into a textbox and submits it and the text is entered into a
database. In that case, probably the best way to deal with the "magic
quotes" is to use something like this:

if (!get_magic_quotes_gpc()) {
$data=addslashes($_POST['data']);
}

as in the example at PHP.net. I suppose the best solution depends on how
Robert wants to use the text immediately...

- JP
Jul 17 '05 #6
In article <25SMc.161854$IQ4.137836@attbi_s02>,
"kingofkolt" <je**********@comcast.net> writes:
[snip]

Well, I guess I was supposing that Robert's situation was this: a user
enters text into a textbox and submits it and the text is entered into a
database. In that case, probably the best way to deal with the "magic
quotes" is to use something like this:

if (!get_magic_quotes_gpc()) {
$data=addslashes($_POST['data']);
}

as in the example at PHP.net. I suppose the best solution depends on how
Robert wants to use the text immediately...


I won't argue with that. In fact: Unless he has direct control over
the server, the above would be a very good idea.

My point was that, if he *does* have control over the server, it's
safer to leave magic_quotes_gpc on, and use stripslashes() on the
variables in which he knows he doesn't want the escapes. He's less
likely to have a security problem if he fails to run stripslashes()
when he meant to than he would failing to run addslashes() when he
needs to.

Then again: I'm one of those dinosaurs that believes in application-
layer proxy firewalls and "That which isn't explicitly allowed, is
denied" policy ;).

--
Jim Seymour | PGP Public Key available at:
WARNING: The "From:" address | http://www.uk.pgp.net/pgpnet/pks-commands.html
is a spam trap. DON'T USE IT! |
Use: js******@LinxNet.com | http://jimsun.LinxNet.com
Jul 17 '05 #7
Jim Seymour wrote:
In article <25SMc.161854$IQ4.137836@attbi_s02>,
"kingofkolt" <je**********@comcast.net> writes:
[snip]
Well, I guess I was supposing that Robert's situation was this: a user
enters text into a textbox and submits it and the text is entered into a
database. In that case, probably the best way to deal with the "magic
quotes" is to use something like this:

if (!get_magic_quotes_gpc()) {
$data=addslashes($_POST['data']);
}

as in the example at PHP.net. I suppose the best solution depends on how
Robert wants to use the text immediately...

I won't argue with that. In fact: Unless he has direct control over
the server, the above would be a very good idea.

My point was that, if he *does* have control over the server, it's
safer to leave magic_quotes_gpc on, and use stripslashes() on the
variables in which he knows he doesn't want the escapes. He's less
likely to have a security problem if he fails to run stripslashes()
when he meant to than he would failing to run addslashes() when he
needs to.

Then again: I'm one of those dinosaurs that believes in application-
layer proxy firewalls and "That which isn't explicitly allowed, is
denied" policy ;).

Thanks everyone for your input on this question. In my case, input
strings are either put into the database or compared to strings already
there. My DBMS's ( DB2 ) way of quoting apostrophes is to double them,
which I am doing on variables of type character and varchar. I never
execute strings directly from the client, thus the risk is minimal, so
I'm going with magic_quotes_gpc off.

Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Graham Thomson | last post by:
Hi, I've recently started looking at PHP and MY SQL within Dreamweaver MX. I'm usin PHPMyAdmin and put some example code from my tutorial book into it and pressed "Go". However, the code...
7
by: Margaret MacDonald | last post by:
I've been going mad trying to figure out how to do this--it should be easy! Allow the user to enter '\_sometext\_', i.e., literal backslash, underscore, some text, literal backslash, underscore...
4
by: Tom Chadwin | last post by:
Hello all Using PHP 4.1.2, I am seeing intermittent visible escaping backslashes in my HTML output. Try refreshing the following page a few times to see what I mean: ...
6
by: Mikheil | last post by:
Hello! I need to translate file destination name with one backslashes "c:\program files\directory\file.txt" to string containing double backslashes "c:\\program files\\directory\\file.txt" If...
1
by: Alastair Cameron | last post by:
VB6, MSXML 3.2 installed: Q1. I am having a problem selecting nodes with XPATH expressions when an attribute values contain backslashes (\\) in as part of its value: For example the...
6
by: supercomputer | last post by:
I am using this function to parse data I have stored in an array. This is what the array looks like: , , , , , , , , , , , , , , , , , , , , , , , ] This is the code to parse the array:
2
by: cricfan | last post by:
I'm parsing a text file to extract word definitions. For example the input text file contains the following content: di.va.gate \'di_--v*-.ga_-t\ vb pas.sim \'pas-*m\ adv : here and there :...
2
by: wylbur37 | last post by:
When using a form with an input textbox such as the following ... <input type="text" name="field1" size=30> I discovered that when a backslash (\) is typed into the textbox, when I later check...
0
by: DeadAtBirth | last post by:
I have an XML file which have nodes that contain filepaths, e.g.<path>c:\SomeDirectory\SomeFile.txt</path> I'm using an XmlDocument and XPath query to try and find a node XmlDocument doc = new...
3
by: =?Utf-8?B?cmFuZHkxMjAw?= | last post by:
OpenFileDialog gives me the following, which I place in tbDevPath.Text: x:\\myVob\\mySolution\\mySolution.sln I really need this path to be single-backslashes, not double-backslashes, so I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.