.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.

ADVERTISEMENT

UTF-8 And Urlencode In PHP

Feb 5, 2006

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 View Related

If With Urlencode

Apr 4, 2006

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`";
$result=mysql_query($query1);
list($adid,$desc)=mysql_fetch_row($result);
while(list($adid,$desc)= mysql_fetch_row($result))
$qry="update `table1` set `table1`.`description`='",urlencode($desc),"' where `table1`.`id`=$adid";
$result=mysql_query($qry);


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

View 1 Replies View Related

%27 And ' - Urlencode

Sep 9, 2005

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 View Related

Urlencode()

Aug 16, 2006

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 View Related

Test For Urlencode

Nov 15, 2002

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 View Related

Urlencode Vs Rawurlencode

Jul 17, 2005

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 View Related

Urlencode And $_GET

Nov 22, 2005

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

for example:
urlencode turns
HOYDM_EXC_#4_NAT
into HOYDM_EXC_%234_NAT

When I use it in an url
index.php?id=HOYDM_EXC_%234_NAT

$_GET[id]=HOYDM_EXC_

Am I doing something wrong ?

View 27 Replies View Related

Stripslashes And Urlencode

Aug 11, 2002

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 View Related

Urlencode Problems

Aug 26, 2005

I am having problems with running urlencode(select * from myfile where
field like '%0002%'), in particular the like section, what I get is...
like+%27%250002%25%27
....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 View Related

Serialize/urlencode

Aug 17, 2006

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:

graphcode.php?datawk=$sdatawk&datay=$sdatay&data=$sdata

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:

NULL

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

View 10 Replies View Related

Urlencode(addslashes(chr(0)))

Oct 23, 2005

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 View Related

Urlencode And Javascript

Oct 15, 2004

I have a link like this on a page:

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

The javascript function:

function popup(aURL)
{
alert(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 View Related

Urlencode In JavaScript?

Feb 24, 2006

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 View Related

URLencode Utf-8 Or ISO-8859-1

Oct 17, 2007

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 View Related

Urlencode Problem

Oct 21, 2006

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 View Related

Okay To Urlencode() Entire URL?

Feb 5, 2007

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:

/people/profiles/profiles.php?pageNum_rs_profiles=1&totalRows_rs_profiles=13&searchInfo=johnny&do_search=Find

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 View Related

Urlencode In Preg_replace?

Jun 11, 2011

$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 View Related

Use Urlencode In Script?

Sep 12, 2010

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.

<?php
$user_id="john_smith@ourwiki.com";
[code]......

View 1 Replies View Related

Urlencode() And Stripslashes(urldecode())

May 20, 2001

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 View Related

PHP's Urlencode() = Create Friendly URL?

May 5, 2005

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 View Related

Urlencode A File With Newlines ...

Feb 27, 2006

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 View Related

Urlencode Giving Error With @

Dec 5, 2007

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 View Related

Urlencode & Urldecode On Datetime

May 18, 2006

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 View Related

Urlencode Str_replace Function

Dec 15, 2010

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).

[code]...

View 3 Replies View Related

Get Url With Special Characters Without Urlencode:ing Them?

Jul 23, 2009

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 View Related

Run The Urlencode Function Without Converting # Or %?

Nov 4, 2009

It is possible to run the urlencode function without converting # or %?

View 4 Replies View Related

URLEncode Return Different Value In ASP Classic?

Jun 6, 2011

Application which integrate with PayPal.To do so, it makes some call via API, and in these calls have to pass some parameters that are URLEncoded.don't get it working because Server.URLEncode of classic asp returns me something strange.

Code:@CODEPAGE="65001"
Response.Charset = "UTF-8"
response.write(server.URLEncode("xxxx_1344559025_biz_api1.yy"))

[code]...

Both files are encoded in UTF-8, do that on DreamWeaver with CTRL+J > title/encoding.different answer in ASP classic and PHP?

View 1 Replies View Related

Urlencode The Value In Header(Location: Value)?

Feb 23, 2011

This is PHP.I do

header("Location: " . $url)
and works great. But If I do
header("Location: " . urlencode($url))

I'm redirected to some weird place like $url/$url which gives me a 404, of course.But I do want to urlencode my url because it's made of user provided data. How can I do it?

View 3 Replies View Related

Addslashes+urlencode+urldecode+stripslashes?

Aug 28, 2001

I have a set of forms that make up a person's details, and I want for people to be able to view their details and add/edit/delete entries as one would likely want to.

When they fill out one of the forms, I take the text entries ( INPUT TYPE=TEXTs and TEXTAREAs) and I addslashes() and urlencode() the values before inserting them into the MySQL database.

The values look ok in the DB ( A+small+sentence etc.)

When I want to edit a form, I do my SELECT, and urldecode() and stripslashes() in that order.

So why is it that in the edit form, the <INPUT TYPE=TEXT> form elements with multiple-word values are chopped at the first word as if I hadn't done any safeguarding at all??

eg. Two+Words comes back as Two.

Mind you, the TEXTAREAs are returned OK - Two Words.

View 6 Replies View Related

Htmlentities(urlencode($userinput)) Overkill?

Oct 14, 2004

PHP manual recommends the following to encode URLs:

<?php
echo '<a href="mycgi?foo=', htmlentities(urlencode($userinput)), '">'
?>

However this makes little sense to me as urlencode converts everything but -_ to %xx, and % has no equivalent html entity. So htmlentities() will not transform anything in urlencode($userinput).

It would makes sense in this case:

<?php
echo '<a href="mycgi?foo=', htmlentities(urlencode($userinput_1) . '&' . urlencode($userinput_2)), '">'
?>

Then htmlentities is useful as the & get translated into its &amp; entity.

Or am I missing something?

View 1 Replies View Related

Data Being Stripped Off After Ampersand In URL Even When Using Urlencode?

Mar 15, 2011

I am passing ampersands in a URL which go into a get requeste.g.[URL]....I have tried to urlencode the & so that it is a valid URL [URL]...but the & Run section of the URL is being cut off in the get request.I'm thinking this might have something to do with my mod_rewriteRewriteRule ^label/([^/]*)$ /index.php?label=$1 [NC]the get request is$label = $_GET['label'];

View 2 Replies View Related

Minus Symbol In URL (rawurlencode Vs Urlencode)

Feb 28, 2011

I've tried using rawurlencode and urlencode, both give me "&" and the other "+".

What i'm asking is, is there a PHP function that puts "-" in between words, like on Stack Overflow?

View 5 Replies View Related

Is Urlencode() A Safe Way To Allow Valid UTF-8 Strings In The URL

Jan 7, 2010

I have user submitted tags that can be any type of (valid) UTF-8 string. I want to know if it is safe to include them in the URL merly by running them through urlencode().

In other words, is urlencode() safe to use for valid UTF-8 strings? (by valid I mean id have already force-encoded them to UTF-8)

View 3 Replies View Related

Urlencode - Properly Url Encode A String?

Jan 20, 2011

I'm making a search page, where you type a search query and the form is submitted to search.php?query=your query. What PHP function is the best & I should use for encoding/decoding the search query?

View 2 Replies View Related

Urlencode - URL GET Parameters Inside URL Parameter?

Jan 17, 2011

I am developing facebook/myspace content share buttons. The Facebook link takes you to a URL on my website, but I need to pass additional parameters to my URL along with the parameters passed to facebook. Here's my example:[URL]Do I need to escape something inside the "u" parameter?

View 2 Replies View Related

Filter_var Regex Urlencode Validate?

Apr 14, 2009

I don't see why this code doesn't work (only for the filter_input):

PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Test</title>
</head>

[Code]..

View 7 Replies View Related

UTF-8 Server.UrlEncode Problem In ASP Classic?

Mar 5, 2009

I'm having a bit of bother URL encoding a string of UTF-8 encoded text to pass over HTTP. I am using Server.URlEncode in classic ASP (vbscript) to do the encoding on the "character.

It produces the following string, The system I am talking to over HTTP is PHP however and it cannot decode this string. Using a PHP encoder at http://www.albionresearch.com/misc/urlencode.php the same character encoded using the PHP URL encoding method comes out as, Does anyone know how I can successfully encode my UTF-8 encoded strings in my ASP so that the PHP system can successfully decode them?

View 1 Replies View Related

ITunes Will Read The XML But Will Not Download The Mp3's - Urlencode

Mar 21, 2011

I am placing this in the PHP sections because I think you all will know this answer the quickest. I am creating a podcast. I have created the XML file successfully. I have placed the file on my server and have gotten one of my podcast clients (Media Monkey) to pick it up and the mp3 files within it successfully. My issue is that when i try an get iTunes to work with it there is problems. iTunes will read the XML, but will not download the mp3's. I'm pretty sure I know why, but there is a huge catch-22 in the deal. To protect my content my CDN offers a method by where I add some query parameters to the end of the mp3 file to protect it from illegal downloads. It look like this (not actual file)

Code: [URL] Using this string in the XML makes it validate correctly. The issue is because this link is urlencoded, the XML validates, but iTunes will not process the link as a valid link. Now if I remove the urlencoded part of the link, the XML will not validate and then iTunes will not even read the XML file. This is the link without encoding.

Code: [URL] See where I'm going? Anyone have a solution? How do I get around this catch-22? I need a way to pass the un-encoded link in the XML file, but still make it validate.

View 1 Replies View Related

Add Session Variables To Url (urlencode / Decode)

Apr 25, 2010

I have finished reading several posts and threads on urlencode/decode and I am still at a loss. Yet I believe that this is the only method that I can use to do what I need to accomplish.

Over view of what I am attempting to do...

I have a page that is simply a form that collects name, address etc. from this it gets posted to another page and converted into $_SESSION information. Simple enough.

This page that is being posted to also loads an iFrame that is coming from a different domain. The information in the $_SESSION vars, I need to pass to this iFrame page.

[Code].....

and turn it into the encoded url that I am looking for? Further once that is done how to I get the session vars back as session vars on that new domain iFrame page...

View 9 Replies View Related

Urlencode() - Implement The HtDig/PHP Searhc Engine

Jul 2, 1999

I'm trying to implement the HtDig/PHP searhc engine I found here on DevShed and I'm not getting the query string from the form within the PHP program. The function being used is to aquire the query string is: $words = EscapeShellCmd(urlencode($search));
The form is simply this: Code:

View 1 Replies View Related

Link Made With Urlencode() Wont Work?

Nov 1, 2009

I have my site analyzer script nearly working, butthe link that I am trying to pass back to the query is not being accepted.The easiest way to explain what I mean is to show you the script on my server:When you follow the link below you will see an outputlist of links that are taken from the website ( one of mine)Clicking on the "open" works fine ( that url is openedin a new window) but clicking on the displayed link is suppoedo result in the link being queried - but it doesn't work.

View 2 Replies View Related

Preg_replace Apply String Function (like Urlencode) In Replacement

Aug 24, 2010

i want to parse all links in html document string in php in such way: replace href='LINK' to href='MY_DOMAIN?URL=LINK', so because LINK will be url parameter it must be urlencoded. i'm trying to do so:

preg_replace('/href="(.+)"/', 'href="http://'.$host.'/?url='.urlencode('${1}').'"', $html);

but '${1}' is just string literal, not founded in preg url, what need i do, to make this code working?

View 2 Replies View Related

.htaccess - Joomla Htaccess Rewrite Exception For Custom Index?

May 29, 2011

I am trying to make an exception to the default htaccess from Joomla 1.6.3 for having a friendly url for my own php scripts.The idea is that the following already working url:[URL]The rule i placed in the htaccess is working, but reverts it to showing the php with the parameter... .htaccess:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} base64_encode[^(]*([^)]*) [OR]

[code]...

View 1 Replies View Related

.htaccess - Redirecting All A Website Access To Index Using Htaccess ?

Apr 7, 2011

There is a number of answer of how to do it, but I can't find a reason or a set of reasons why it's a nice thing to do.

View 4 Replies View Related

ADVERTISEMENT