سؤال

In my project I need to pass a simple and short query in a GET variable, using urlencode.

Some of the characters seem to be get modified after I perform the URL Decode and as a result, no database results are returned.

I was wondering if someone can help me identify why this is and how to troubleshoot this problem?

Many thanks in advance!

Before URL Encode:

((u.firstname LIKE '%Carol%') AND (u.lastname LIKE '%Enriquez%')

After URL Endode:

%28%28u.firstname+LIKE+%27%25Carol%25%27%29+AND+%28u.lastname+LIKE+%27%25Enriquez%25%27%29%29++

After URL Decode:

((u.firstname LIKE 'Êrol%') AND (u.lastname LIKE '%Enriquez%')

هل كانت مفيدة؟

المحلول

This can happens if you decode it twice.

Observe: http://3v4l.org/uK5a6

var_dump(urldecode(urlencode("((u.firstname LIKE '%Carol%') AND (u.lastname LIKE '%Enriquez%')")));
var_dump(urldecode(urldecode(urlencode("((u.firstname LIKE '%Carol%') AND (u.lastname LIKE '%Enriquez%')"))));

string(64) "((u.firstname LIKE '%Carol%') AND (u.lastname LIKE '%Enriquez%')"
string(62) "((u.firstname LIKE '�rol%') AND (u.lastname LIKE '%Enriquez%')"

% is a special character used in URL encoding. %Ca might be Ê

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top