0

Hai everybody,

I need help in the following value store in database double quotes
"$plan['plantitle'] "

for example
has commented on your plan "test "

anybody plz help

public function notifyCommentOnPlan($me, $comment,$plan,$section)
    {
        //var_dump($comment['personal_id']);exit;
        //notify Plan owner
        if($plan['personal_id']!=$me->getId())
        {
            $commentPlan = new Notification();
            $commentPlan->setPersonalId($plan['personal_id']);
            $commentPlan->setSenderId($me->getId());
            $commentPlan->setTypeId(3);
            $commentPlan->setMessage(ucfirst($me->getFullName()) . " has commented on your plan " .$plan['plantitle'] );
            $commentPlan->setUserViewed(0);
            $commentPlan->setRelativeItemId($plan['id']);
            $commentPlan->setSection('me');
            $commentPlan->save();   
        }
3
Contributors
2
Replies
16
Views
4 Years
Discussion Span
Last Post by IIM
0

It can be done in number of ways depending on data that you are storing.
Like:-
1) addcslashes is useful when you want to store data containing data like C i.e., \n etc.More info at manual.

 $originaltext = 'This text does NOT contain "" a new-line!';
  $encoded = addcslashes($originaltext, '"');
  $decoded = stripcslashes($encoded);
echo $decoded;

2) htmlspecialchars is useful when you want to convert special characters to HTML entities.More info at manual and then decode using htmlspecialchars_decode .

3) You can use addslashes() that is similar to

$data = "test";
echo "\"$data\"";

4)Use htmlentities — Convert all applicable characters to HTML entities.
and html_entity_decode - to decode html entities back to html

$orig = "I'll \"walk\" the <b>dog</b> now";

$a = htmlentities($orig);

$b = html_entity_decode($a);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.