Baabu Posted May 4, 2008 Share Posted May 4, 2008 Hello every one, i m stuck with a "+" symbol in my database and php i have an item listed with it's name "AZ+" in my database but when i try to add it to an invoice it says not found bcoz in the name variable through which "AZ+" is passed to invoice page it only takes "AZ" not the plus i guess it is something like decode or encode can anyone tell me how to avoid this decode or encode condition and this "AZ+" should work Best Regards Baabu Link to comment https://forums.phpfreaks.com/topic/104021-how-to-avoid-symbol/ Share on other sites More sharing options...
tronicsmasta Posted May 4, 2008 Share Posted May 4, 2008 You might try something like this: $text_to_database = "this text is going to the db + and contains a plus symbol."; $replace_this = array("+"); $replace_with = array("&plus"); $new_text_to_database = str_replace($replace_this, $replace_with, $text_to_database); echo "$new_text_to_database"; //will echo this text is going to the db &plus and contains a plus symbol. //now reverse when retrieving $text_from_database = "this text is going to the db &plus and contains a plus symbol."; $replace_this = array("&plus"); $replace_with = array("+"); $new_text_from_database = str_replace($replace_this, $replace_with, $text_from_database); echo "$new_text_from_database"; //will echo this text is going to the db + and contains a plus symbol. Reference: http://tinyurl.com/4k8b9s GL Link to comment https://forums.phpfreaks.com/topic/104021-how-to-avoid-symbol/#findComment-532592 Share on other sites More sharing options...
Rohan Shenoy Posted May 4, 2008 Share Posted May 4, 2008 Try using urldecode() whole passing it to the variable and urlencode() while getting it back from variable. Link to comment https://forums.phpfreaks.com/topic/104021-how-to-avoid-symbol/#findComment-532599 Share on other sites More sharing options...
tronicsmasta Posted May 4, 2008 Share Posted May 4, 2008 Try using urldecode() whole passing it to the variable and urlencode() while getting it back from variable. good call... thats probably easier... lol Link to comment https://forums.phpfreaks.com/topic/104021-how-to-avoid-symbol/#findComment-532608 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.