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; Link to comment https://forums.phpfreaks.com/topic/124265-solved-htmlspecialchars/ 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). Link to comment https://forums.phpfreaks.com/topic/124265-solved-htmlspecialchars/#findComment-641694 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. Link to comment https://forums.phpfreaks.com/topic/124265-solved-htmlspecialchars/#findComment-641696 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 <[email protected]> ? something like that? Link to comment https://forums.phpfreaks.com/topic/124265-solved-htmlspecialchars/#findComment-641698 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) Link to comment https://forums.phpfreaks.com/topic/124265-solved-htmlspecialchars/#findComment-641702 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) Link to comment https://forums.phpfreaks.com/topic/124265-solved-htmlspecialchars/#findComment-641704 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 protected] or name <[email protected]> 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 Link to comment https://forums.phpfreaks.com/topic/124265-solved-htmlspecialchars/#findComment-641705 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 :-/ Link to comment https://forums.phpfreaks.com/topic/124265-solved-htmlspecialchars/#findComment-641707 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> Link to comment https://forums.phpfreaks.com/topic/124265-solved-htmlspecialchars/#findComment-641708 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 ??? Link to comment https://forums.phpfreaks.com/topic/124265-solved-htmlspecialchars/#findComment-641711 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.