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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.