473,398 Members | 2,368 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,398 software developers and data experts.

How to use escape characters (particularly #) with $_GET

I don't have a lot of experience using $_GET.

I need to know how to pass characters in using the $_GET method. The
character I'm having a problem with right now is '#', but I'm sure
there are others.

Could anyone give me a list of characters that need to be escaped
using $_GET, and then also how to use them?

Also, could you tell me if any characters simply are not allowed in a
get?

Example:

getData.php?type=edit&user=myName&item=Item#1

Thanks,

Chad

Mar 20 '07 #1
5 8213
ch***********@gmail.com wrote:
I don't have a lot of experience using $_GET.

I need to know how to pass characters in using the $_GET method. The
character I'm having a problem with right now is '#', but I'm sure
there are others.

Could anyone give me a list of characters that need to be escaped
using $_GET, and then also how to use them?

Also, could you tell me if any characters simply are not allowed in a
get?

Example:

getData.php?type=edit&user=myName&item=Item#1

Thanks,

Chad
urlencode() your parameters.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 20 '07 #2
On Mar 19, 8:45 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
chad.a.mor...@gmail.com wrote:
I don't have a lot of experience using $_GET.
I need to know how to pass characters in using the $_GET method. The
character I'm having a problem with right now is '#', but I'm sure
there are others.
Could anyone give me a list of characters that need to be escaped
using $_GET, and then also how to use them?
Also, could you tell me if any characters simply are not allowed in a
get?
Example:
getData.php?type=edit&user=myName&item=Item#1
Thanks,
Chad

urlencode() your parameters.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -
I'm trying to go from javascript (making the call) to php.

For example:

function getData()
{
var user = "user1" ;
var item = encodeURI( "Item #1" ) ;
xmlHttp.open( 'GET' , 'addData.php?user=' + user + '&item=' +
item ) ;
}
However, the encodeURI() function on the string give returns the
following:

Item%20#1

So, it is leaving the pound sign, which is messing me up.

Any other thoughts? Perhaps I'm not using the functions correctly?

Thanks for the help!

Chad

Mar 20 '07 #3
ch***********@gmail.com wrote:
On Mar 19, 8:45 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>chad.a.mor...@gmail.com wrote:
>>I don't have a lot of experience using $_GET.
I need to know how to pass characters in using the $_GET method. The
character I'm having a problem with right now is '#', but I'm sure
there are others.
Could anyone give me a list of characters that need to be escaped
using $_GET, and then also how to use them?
Also, could you tell me if any characters simply are not allowed in a
get?
Example:
getData.php?type=edit&user=myName&item=Item#1
Thanks,
Chad
urlencode() your parameters.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -

I'm trying to go from javascript (making the call) to php.

For example:

function getData()
{
var user = "user1" ;
var item = encodeURI( "Item #1" ) ;
xmlHttp.open( 'GET' , 'addData.php?user=' + user + '&item=' +
item ) ;
}
However, the encodeURI() function on the string give returns the
following:

Item%20#1

So, it is leaving the pound sign, which is messing me up.

Any other thoughts? Perhaps I'm not using the functions correctly?

Thanks for the help!

Chad
Chad,

First of all, it's urlencode() - not encodeURI(). I have no idea what
that function does - it's not part of the PHP standard library.

And you're using AJAX - which is something completely different. Not
being an AJAX user myself, I can't say what your problem is. All I know
is I use urlencode() with some regularity and it works fine. I've also
tried strings with a '#' in them and it's OK.

The '#' is used in an href to indicate a tag (<a name=...>) on a page.
Perhaps AJAX is getting confused. I wouldn't know. Or maybe your
encodeURI() function isn't doing the same thing.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 20 '07 #4
ch***********@gmail.com wrote:
On Mar 19, 8:45 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>chad.a.mor...@gmail.com wrote:
I don't have a lot of experience using $_GET.
I need to know how to pass characters in using the $_GET method. The
character I'm having a problem with right now is '#', but I'm sure
there are others.
Could anyone give me a list of characters that need to be escaped
using $_GET, and then also how to use them?
Also, could you tell me if any characters simply are not allowed in a
get?
Example:
getData.php?type=edit&user=myName&item=Item#1
Thanks,
Chad

urlencode() your parameters.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -

I'm trying to go from javascript (making the call) to php.

For example:

function getData()
{
var user = "user1" ;
var item = encodeURI( "Item #1" ) ;
xmlHttp.open( 'GET' , 'addData.php?user=' + user + '&item=' +
item ) ;
}
However, the encodeURI() function on the string give returns the
following:

Item%20#1

So, it is leaving the pound sign, which is messing me up.

Any other thoughts? Perhaps I'm not using the functions correctly?
Indeed.

encodeURI leaves ; / ? : @ & = + $ , # all intact.

What you need in Javascript is escape(), not encodeURI().

Tip: Buy a good JS book and you never fall for this kind of thing again.
I recommend Javascript, the definitive guide, by Flanagan (O Reilly)

Regards,
Erwin Moller
>
Chad
Mar 20 '07 #5
On Mar 20, 11:20 am, Erwin Moller
<since_humans_read_this_I_am_spammed_too_m...@spam yourself.comwrote:
chad.a.mor...@gmail.com wrote:
On Mar 19, 8:45 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
chad.a.mor...@gmail.com wrote:
I don't have a lot of experience using $_GET.
I need to know how to pass characters in using the $_GET method. The
character I'm having a problem with right now is '#', but I'm sure
there are others.
Could anyone give me a list of characters that need to be escaped
using $_GET, and then also how to use them?
Also, could you tell me if any characters simply are not allowed in a
get?
Example:
getData.php?type=edit&user=myName&item=Item#1
Thanks,
Chad
urlencode() your parameters.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -
- Show quoted text -
I'm trying to go from javascript (making the call) to php.
For example:
function getData()
{
var user = "user1" ;
var item = encodeURI( "Item #1" ) ;
xmlHttp.open( 'GET' , 'addData.php?user=' + user + '&item=' +
item ) ;
}
However, the encodeURI() function on the string give returns the
following:
Item%20#1
So, it is leaving the pound sign, which is messing me up.
Any other thoughts? Perhaps I'm not using the functions correctly?

Indeed.

encodeURI leaves ; / ? : @ & = + $ , # all intact.

What you need in Javascript is escape(), not encodeURI().

Tip: Buy a good JS book and you never fall for this kind of thing again.
I recommend Javascript, the definitive guide, by Flanagan (O Reilly)

Regards,
Erwin Moller


Chad- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -
Thanks for the help Erwin and Jerry. I will definitely check out the
book you mentioned. I'm finding that the more in depth that I go, the
better off I'd be with a book.

THANKS!!

Mar 22 '07 #6

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

Similar topics

2
by: BTnews | last post by:
Hi, Can anyone here point me at a definitive guide or tutorial about using escape characters when building SQL queries from user entered data? I'm especially interested in info on this in regard...
7
by: teachtiro | last post by:
Hi, 'C' says \ is the escape character to be used when characters are to be interpreted in an uncommon sense, e.g. \t usage in printf(), but for printing % through printf(), i have read that %%...
18
by: Steve Litvack | last post by:
Hello, I have built an XMLDocument object instance and I get the following string when I examine the InnerXml property: <?xml version=\"1.0\"?><ROOT><UserData UserID=\"2282\"><Tag1...
4
by: Guadala Harry | last post by:
I need to place the following into a string... How can I properly escape the % " / < and > characters? <table width="100%" border="0" cellspacing="0" cellpadding="4px" class="hfAll"></Table> ...
3
by: Guadala Harry | last post by:
I'd like to know the answer to the following question so I can know what to expect with regard to other similar uses of escape characters and strings. While everything works fine - I'd like to know...
0
by: Mike Cooper | last post by:
Hi everyone, I am accessing several binary (PCL) files sequentially using a for loop. For each file I am using the fileget() command to populate the contents of the file into a string. I use...
4
by: Jim Carlock | last post by:
Does PHP provide a function to extract the rightmost characters from a string? For example, the VB/ASP equivalent... sStateAbbr = Right$(sCityState, 2) Thanks. Jim Carlock
15
by: pkaeowic | last post by:
I am having a problem with the "escape" character \e. This code is in my Windows form KeyPress event. The compiler gives me "unrecognized escape sequence" even though this is documented in MSDN....
131
by: Lawrence D'Oliveiro | last post by:
The "escape" function in the "cgi" module escapes characters with special meanings in HTML. The ones that need escaping are '<', '&' and '"'. However, cgi.escape only escapes the quote character if...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.