The following warnings occurred: | ||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
DB insert and charset - Printable Version +- UserSpice (https://userspice.com/forums) +-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23) +--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26) +--- Thread: DB insert and charset (/showthread.php?tid=909) |
DB insert and charset - MHALL1 - 01-10-2018 Hi, I have a 'trading name' input box and if the '&' symbol is entered, this is written to the database as '& amp;'. I then run a check that if the current value doesn't match what's in the DB, update the entry. Currently it always thinks that they don't match (even though the do if I dump the variable). If I update the & amp; to &; in phpMyAdmin the issue goes away. Is there a way I can force either the insert or update classes to write it as & rather than '& amp;'? Hope that makes sense, Cheers DB insert and charset - MHALL1 - 01-10-2018 I've worked around this by us the below: Code: $trading_name = str_replace("&(amp)","&",$trading_name); DB insert and charset - Brandin - 01-10-2018 Thanks for posting your workaround, Matt! I think a better solution would be to allow the DB to insert the special character value (&) and on your comparison, use htmlspecialchars. http://php.net/manual/en/function.htmlspecialchars.php DB insert and charset - MHALL1 - 01-10-2018 Thanks, took of couple of extra lines to create additional variables but have now taken that approach |