Hi Guys,
I am making some AJAX calls and passing some POST variables. The POST parameters happen to contain "+" character. It is something like prod1=A4+&prod2=fullsize. When I try to read the $_POST[prod1] it returns "A4 ". There is no + sign and it replaced by a white space instead. Am I doing something wrong? How can I read POST variables that contains "+" character.
Thanks in advance.
POST Variables contains "+"
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: POST Variables contains "+"
urlencode()
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: POST Variables contains "+"
I am making an AJAX call. So, I am building up the string using the javascript "+" to concatenate various variables for POST. Then I am using
. So, how can I use the urlencode() here since I am creating the parameter string in javascript?http_request.open('POST', url, true);
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: POST Variables contains "+"
I think it's this in js:leon_nerd wrote:I am making an AJAX call. So, I am building up the string using the javascript "+" to concatenate various variables for POST. Then I am using. So, how can I use the urlencode() here since I am creating the parameter string in javascript?http_request.open('POST', url, true);
Code: Select all
url = escape(url);mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: POST Variables contains "+"
Actually, you may only want to escape() the actual values and not the full url.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: POST Variables contains "+"
Ahh...I got it working. So silly of me. Just a simple encodeURIComponent() did the trick. Thanks a lot guys for your inputs. I really appreciate your time 