Page 1 of 1

Quotation mark in php

Posted: Sat Mar 12, 2011 12:30 pm
by shuhail
Hi,

I need to write the following line in php:

Code: Select all

<a href="javascrip:void(0)" onclick="javascript:chatWith('janedoe')">Chat With Jane Doe</a>
but I need to replace the name "Jane Doe" with names selected from my database.

Code: Select all

echo "<a href='javascript:void(0)' onclick='javascript:chatWith("" . $nm . "")'>" .$nm. "</a>";
here I need 3rd type of quotation mark !!!
Please someone tell me how to fix this.


Thanks.

Re: Quotation mark in php

Posted: Sat Mar 12, 2011 12:45 pm
by Darhazer
You don't need, you can escape quotes with a slash

Code: Select all

echo "<a href=\"javascrip:void(0)\" onclick=\"javascript&#058;chatWith('$name')\">Chat With $name</a>";

Re: Quotation mark in php

Posted: Sat Mar 12, 2011 12:46 pm
by shuhail

Code: Select all

echo "<tr><td><a href=\"javascript:void(0)\" onclick=\"javascript:chatWith('".$nm1."')\">".$nm."</a></td></tr>";

Thanks. It works.