phpretard Posted September 15, 2008 Share Posted September 15, 2008 I would like to insert "htmlspecialchars" into my DB when a user puts in single or double quotes. I can't make it work in testing...(darn it) So if: $insert="Randal's Appraisals, LLC"; I would like to INSERT ->Randal's Appraisals, LLC OR " = " I have been all over and here I am am again... Any help? NONE OF THESE WORK: $CompanyName="Randal's Appraisals, LLC"; $CompanyName2="Randal's Appraisals, LLC"; $Com=htmlentities($CompanyName, ENT_QUOTES); $Com2=htmlspecialchars_decode($CompanyName2, ENT_QUOTES); echo $Com; echo "<br><br>"; echo $Com2; Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted September 15, 2008 Share Posted September 15, 2008 when you echo something from htmlentities() it will show up in the browser looking like it didn't work because the browser is changing the entities to the correct values. View the source and see if it really changed them. (htmlentities() with ENT_QUOTES is the proper way to do it). Quote Link to comment Share on other sites More sharing options...
phpretard Posted September 15, 2008 Author Share Posted September 15, 2008 Good Call! How can I apply this the the From line in an email? It stops at the single quote. Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted September 15, 2008 Share Posted September 15, 2008 What are you trying to put in for the From: header? Randal's Appraisals, LLC <myemail@mydomain.com> ? something like that? Quote Link to comment Share on other sites More sharing options...
phpretard Posted September 15, 2008 Author Share Posted September 15, 2008 No I am using PHP Mailer and the line is: $CompanyName="Randal's Appraisals, LLC"; $mail->FromName = "$CompanyName"; In the email Sent it now doesn't stop at "Randal" (Thank you) The From Line Reads " Randal\'s Appraisals, LLC " (In The Email) Quote Link to comment Share on other sites More sharing options...
phpretard Posted September 15, 2008 Author Share Posted September 15, 2008 Correction The DB field holds: Randal'sAppraisals, LLC The from Line Reads: "Randal\\" (In the email) Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted September 15, 2008 Share Posted September 15, 2008 As far as email headers go, I'm no expert, but I suppose you're trying to use a character that is not allowed. You WILL need to use the form email@domain.com or name <email@domain.com> for the from headers or the email will likely not get by 99% of email filters. EDIT: just read the standards, seems like any 1-127 of the ascii set of characters is fine... I have no idea then http://www.faqs.org/rfcs/rfc2822 Quote Link to comment Share on other sites More sharing options...
xoligy Posted September 15, 2008 Share Posted September 15, 2008 when you echo something from htmlentities() it will show up in the browser looking like it didn't work because the browser is changing the entities to the correct values. View the source and see if it really changed them. (htmlentities() with ENT_QUOTES is the proper way to do it). this is my db 168 1 asdsad Admin < blah > 2008-09-15 05:19:11 05:19:00 the page <TR><TD width="100%"><p><b style="font-size: 16px;">asdsad</b></TD> <TR><TD style="font-size: 10px;">Posted by: <b><a href="stats.php?id=1">Admin</a> at 05:19 AM <a href="comments.php?id=168">Comments|0</a></font></b></TD> <TR><TD><div class="content-box"><p>< blah ></div></TD> i managed to do it somehow :-/ Quote Link to comment Share on other sites More sharing options...
xoligy Posted September 15, 2008 Share Posted September 15, 2008 with the " u wanted lol 169 1 asdasdsa Admin test 'test' and "test" 2008-09-15 05:24:42 05:24:00 <TH align=left style="padding-left: 5px; font-size: 12px;">September 15th, 2008</TH> <TR><TD width="100%"><p><b style="font-size: 16px;">asdasdsa</b></TD> <TR><TD style="font-size: 10px;">Posted by: <b><a href="stats.php?id=1">Admin</a> at 05:24 AM <a href="comments.php?id=169">Comments|0</a></font></b></TD> <TR><TD><div class="content-box"><p>test 'test' and "test"</div></TD> Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted September 15, 2008 Share Posted September 15, 2008 did you post in the wrong thread xoligy ??? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.