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();   
        }

If I am in the case, I will use htmlentities to encode the text before having it store to database and when query out the data, decode it with html_entity_decode().
Detail on how to use the functions will be on http://php.net/manual/en/function.htmlentities.php

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);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.