.htaccess - GET Var With Urlencode And "&" Bug?

Jul 8, 2011

In my code, I create a link like this:
$link = 'http://www.mydomain.com/'.urlencode($str).'/1';
I use url-rewriting and the rule in my htaccess file looks like this:
rewriteRule ^(.+)/(.*)$ index.php?var1=$1&var2=$2 [NC,L]

This code is working fine for almost every strings.But sometimes, the string to encode contains "&".The urlencode function encodes it corectly, but when I read the $_GET array in php, it looks like this (with $str = 'substring1&substring2'):

'var1' => 'substring1' (without "&")
'substring2' => '' (without "&")
'var2' => 1

I really need the "&" in my var.Is there a way to encode that character to make it works?Also, I really don't know why, but sometimes I get a forbidden http error with some strings passed as var1.Apparently, they have nothing special, for exemple, "Décarie Square" makes that error.Other strings with spaces and "é" are working fine.

View 4 Replies


UTF-8 And Urlencode In PHP

Im having problems URL decoding some strings on my site. First of all, my site uses the UTF-8 charset:

<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

Now, when formatting a link on my site I use the PHP function urlencode, which results in the following code:

View 1 Replies

If With Urlencode

I keep on having error with this code, saying Parse error, unexpected ','. Im not good with PHP.

$query1="SELECT `table1`.`id`,`table1`.`description` FROM `table1`";
while(list($adid,$desc)= mysql_fetch_row($result))
$qry="update `table1` set `table1`.`description`='",urlencode($desc),"' where `table1`.`id`=$adid";

all I want is to save the description urlencode on the table.

View 1 Replies

%27 And ' - Urlencode

Quite a lot of my data has apostrophes in. I'm passing the data using $_POST
and urlencode. So, for example, Joe's becomes Joe%27s.

On the next page, I urldecode and display the name in the META title. It
comes out as Joe's.

When I pass it once again, it becomes Joe's.

View 5 Replies


I have a string in a database row:

Introductory Programming - C & C++

at the same time i have a drop down menu with this item. I need to compare the database row to the posted field but it never matches with urlencode(). Any ideas?

i think the problem is with the plus signs and the ampersand.

View 4 Replies

Test For Urlencode

Is it possible to test if an url is already encoded by urlencode or do i just have to know it?

my problem is this:
I have a central registration process where i just have to pass a scripts url to if the user is not logged in or registered. This script is then either registers the user or logs him in and then sends the user back to page he wanted to access. The script works perfectly fine. But before I want to urlencode() the url I want to test if this hasn't already be done. how? i found out that if you urlencode an encoded string it encodes all the "%" again. Same goes for urldecode(). My idea would be to test for a %25, which is the substitute for %. I dont think this is save enough thou. Is there another way of doing this?

View 3 Replies

Urlencode Vs Rawurlencode

I can see from the manual that the difference between urlencode and
rawurlencode is that urlencode translates spaces to '+' characters, whereas
rawurlencode translates it into it's hex code.

My question is, is there any real world difference between these two
functions? Or perhaps another way of asking the question: *why* are there
two different functions? In what situation would you need one, and not be
able to use the other?

View 3 Replies

Urlencode And $_GET

urlencode turns # into %23
When I sent it thru $_GET, it dissapears, along with anything that comes
after it.

for example:
urlencode turns
into HOYDM_EXC_%234_NAT

When I use it in an url


Am I doing something wrong ?

View 27 Replies

Stripslashes And Urlencode

Can I add stripslashes and urlencode...the way I've tried doesn't work does anyone know how to do this? PHP Code:

View 3 Replies

Urlencode Problems

I am having problems with running urlencode(select * from myfile where
field like '%0002%'), in particular the like section, what I get is...
....which is fine, but when i decode it I get...
like &#3902;'
....I get backslashes before the single quotes and 2 of the leading
zeroes in 0002 are missing.

View 3 Replies


Im trying to pass arrays via the url. I've tried the following:

$sdatawk = serialize(urlencode($datawk));
$sdatay = serialize(urlencode($datay));
$sdata = serialize(urlencode($data));

url looks like this:


on the receiving page:

$tdatawk= unserialize(urldecode($_GET['datawk']));
$tdata = unserialize(urldecode($_GET['datay']));
$tsdata = unserialize(urldecode($_GET['sdata']));

When I do a var_dump of any of the above, I get:


Please help me figure out what I'm doing wrong.

View 10 Replies


why urlencode(addslashes(chr(0))) returns '%5C0'? It seems like it should return '%00' since that's what urlencode(chr(0)) returns. If not that, I could also see it returning '%5C%00' since that's what urlencode('').urlencode(chr(0)) and urlencode(''.chr(0)) return. '%5C0', however, confuses me. Even urlencode(chr(0x5C0)) doesn't return '%5C0' - it returns '%C0'.

View 1 Replies

Urlencode And Javascript

I have a link like this on a page:

echo "<A HREF="javascript:popup('script.php?",
"var1=", urlencode($var1),
"&var2=", urlencode($var2),

The javascript function:

function popup(aURL)
window.open(aURL, '', 'width=500,height=250');
} // popup()

The alert() in the function is just to illustrate my point: When the alert comes up, the URL is not urlencoded anymore, as if javascript decoded it upon passing the argument to popup().

Is that indeed the case? Do all browsers do that or is it just IE? Actually how come it does that?

View 1 Replies

Urlencode In JavaScript?

I have a php page where I output a list of titles and give the option to delete them. When the user clicks on delete, I call the following JavaScript function:

function deleteitem(title) {
if (confirm("Are you sure you want to delete '" + title +"'"))
window.location.href = 'outputadmin.php?del=' + title;

If the user confirms, then the title is deleted from the database. Everything works as long as I don't have a title that contains the '&' (ampersand) character. For example, if I have the following title: 'John & Mary', then after the user confirms his wish to delete, the following url will be sent: Code:

View 9 Replies

URLencode Utf-8 Or ISO-8859-1

I need to URL encode a variable before passing it to a server (xml using curl). When I just use urlencode($data), it doesn't work.

View 5 Replies

Urlencode Problem

I have this: test.php?id=Couldn%27t+Help+Me

which is obviously achieved by urlencode($blah) in my code, yet the query that is based on the code doesn't work. If I take the apostrophe out of the string, the query works.

View 7 Replies

Okay To Urlencode() Entire URL?

I want to pass a url from one page to another and simply want to know if I can urlencode() an entire url. I've done some searching on the net and some say not to do so.(I'm pretty sure it actually is okay....)

So let's say I want to pass page1.php's URI to page2.php.

Using $_SERVER['REQUEST_URI'] I get page1.php's URI as seen below:


If I want to pass the above URI to page2.php, is this the proper way to do so?(Using urlencode to encode the entire above URI...) Code:

View 1 Replies

Urlencode In Preg_replace?

$str = preg_replace("'(look: (.{1,80}))'Ui",
"(look: <a href="dict.php?process=word&q=\1">\1</a>)",$str);

i want to encode url, but how can I do that?can i use urlencode() function in preg_replace?, something like that,

$str = preg_replace("'(look: (.{1,80}))'Ui",
"(look: <a href="dict.php?process=word&q=\1">\1</a>)",$str);

do you have any idea about encoding url in preg_replace?

View 1 Replies

Use Urlencode In Script?

I've been working on a script that can be used for an internal wiki, that will remove the properties for a user who is inactive. I believe I'm almost there but having a problem with the api. I think I need to use urlencode on the $delete path BUT only for the @ in the email address and # in the property. I know how to use urlencode for the whole thing but not on just that. The way it works, is it loops through to get the properties and most of them include # in the name.


View 1 Replies

Urlencode() And Stripslashes(urldecode())

Some times when I use urlencode() and stripslashes(urldecode()) there are still slashes left.

Why is this, and how can I prevent it?

View 1 Replies

PHP's Urlencode() = Create Friendly URL?

I use urlencode() to encode my URL that I want friendly to search engines.

The result is something like: http/www.example.com/word1+word2+word3/word4

Is the plus sign "+" a good delimiter for words? Will Google and other search engins see "word1", "word2" and "word3" as separated words? Should I use "-" or "_" instead?

View 1 Replies

Urlencode A File With Newlines ...

So I can't seem to urlencode a file with newlines ... it just gives me
a series of T_STRING unexpected parse errors...

cat job_description | while read file ; do php -r "echo
urlencode('$file');" ; done > job_description_encoded &&
URL_ENCODED_DESCRIPTION=`cat job_description_encoded`

.... this takes in a job_description file and outputs a file with alot
of errors in the text ... ?

View 6 Replies

Urlencode Giving Error With @

I am trying to encode an email address in a CURL script and it is throwing an error.
Parse error: syntax error, unexpected '@' in /home/jacobb2/jakesserver/bot/index.php on line 33

here is the code $postfields = "email=" . urlencode(email@hotmail.com);
$postfields .= "&password=" . urlencode(pass);

View 1 Replies

Urlencode & Urldecode On Datetime

With the url variable sending as:

.php?date=2006-05-18 11:14:29

How is the entire value preserved, so it may be inserted?

Presently its being definid as: $date = $_GET['date'];

Which inserts as: 2006-05-18

How should urlencode/urldecode look if this is what should be used?

View 1 Replies

Urlencode Str_replace Function

i have the following 2 arrays that i am looking to replace variables from. However my problem is how to tell to not replace variables that are in %XX format. Right now 0 will get replaced with %30, and this will then again get replaced with %%330 (replaced 3 with %33).


View 3 Replies

Get Url With Special Characters Without Urlencode:ing Them?

I would like file_get_contents to get a url that looks like this: [URL]The problem is that it requests (can't post entire link, sorry): ...wapedia.mobi/sv/Gr%C3%B6t which you can see has been urlencoded, that page does not give me any results.

View 1 Replies

Copyrights 2005-15 www.BigResource.com, All rights reserved