|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
gordonisnz Smarty Regular
Joined: 05 Sep 2009 Posts: 70
|
Posted: Fri Jan 15, 2021 11:21 am Post subject: Problem with Smarty and MYSQl - searching spaces |
|
|
Hello.
I've got a problem, and i'm not sure its a smarty issue, or PHP/MYSQL. I think its Smarty.
basically I am creating an online form, and everything works fdine - except for one thing.
it searches my MYSQL database for Country, Region and City.
everything works fine, except for one entry, where the City has as space in the name.
"Diamond harbour" (Without quotes).
Now i've checked the database source, and this city is spelt correctly with just a space (no fancy characters).
When my PHP script passes the array to Smarty - this particular city is "Diamond harbour" with no special characters.
HOWEVER when i searched for this city using the form - it searches "Diamond" - and not the rest of the word.
SMARTY:
I added the following code - expecting it to change the sapvce to %20.
Code: |
{$kaa|escape:'url'}
|
HOWEVER - its changing the URl to:-
Quote: |
Diamond%2520Harbour
|
2520. ? is that right ? |
|
Back to top |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Sat Jan 16, 2021 12:32 am Post subject: |
|
|
The sequence '%2520' is having been double encoded.
So, the first decoding gets '%20' where '%25' is the encoded character '%'.
The second decoding gets ' ' where '%20' is the encoded space character.
It could be the case that when submitting the form, the browser itself will do any necessary and proper encoding. I suppose it depends on the browser because substituting a space with a plus sign could also happen. Maybe it is the difference between POST and GET. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Jan 18, 2021 1:48 pm Post subject: |
|
|
Do you use default escape modifier perhaps? |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Jan 18, 2021 1:49 pm Post subject: |
|
|
bsmither wrote: | Maybe it is the difference between POST and GET. |
It is a different escaping for different data. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|