Re: [PHP-DB] Replacing + with question
On Wednesday 01 October 2003 01:06, Graeme McLaren wrote: This is what I have so far by the string replace function doesn't replace the spaces and display bla bla bla as I want: Probably it's because you're trying to replace spaces with +. Swap your first 2 parameters. $AddressLine1 = urlencode($AddressLine1); $AddressLine1 = str_replace( , +, $AddressLine1); -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* Surprise your boss. Get to work on time. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Replacing + with question
Jason, thank you for reply. I tried switching the 1st 2 parameters in the str_replace function so that it now looks like this: $AddressLine1 = urlencode($AddressLine1); $AddressLine1 = str_replace(+, , $AddressLine1); Unfortunately as I am now replacing the + symbols with a space only the part up to the first space is displayed back to the user. Any ideas? Cheers again, Graeme :) - Original Message - From: Jason Wong [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, September 30, 2003 7:12 PM Subject: Re: [PHP-DB] Replacing + with question On Wednesday 01 October 2003 01:06, Graeme McLaren wrote: This is what I have so far by the string replace function doesn't replace the spaces and display bla bla bla as I want: Probably it's because you're trying to replace spaces with +. Swap your first 2 parameters. $AddressLine1 = urlencode($AddressLine1); $AddressLine1 = str_replace( , +, $AddressLine1); -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* Surprise your boss. Get to work on time. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Replacing + with question
From: Graeme McLaren [EMAIL PROTECTED] Jason, thank you for reply. I tried switching the 1st 2 parameters in the str_replace function so that it now looks like this: $AddressLine1 = urlencode($AddressLine1); $AddressLine1 = str_replace(+, , $AddressLine1); Unfortunately as I am now replacing the + symbols with a space only the part up to the first space is displayed back to the user. Any ideas? I think this whole problem can be solved by putting quotes around your HTML values. echo First Line Of Address: BR input type=\text\ Name=\AddressLine1\ value=\$AddressLine1\BRBR; Now, the ONLY thing you need to do to $AddressLine1 to make it safe to insert into this HTML form element is run htmlentities() on it. $safe_AddressLine1 = htmlentities($AddressLine1); echo First Line Of Address: BR input type=\text\ Name=\AddressLine1\ value=\$safe_AddressLine1\BRBR; I think the whole bit with + and spaces will go away if you do this. Remember that you may see this+that in the URL, but it's decoded automatically when it gets to your PHP script back to this that... ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php