Jump to content

How to avoid "+" symbol


Baabu

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.