mark_nsx Posted November 3, 2006 Share Posted November 3, 2006 Hi there!I'd just like to know how to insert the & character into a mysql DB? say i have to inserta string that contains &.. thanks very much! Quote Link to comment https://forums.phpfreaks.com/topic/26038-dealing-with-the-ampersand-character-in-phpmysql/ Share on other sites More sharing options...
mark_nsx Posted November 3, 2006 Author Share Posted November 3, 2006 for example.. "Management & Staff" Quote Link to comment https://forums.phpfreaks.com/topic/26038-dealing-with-the-ampersand-character-in-phpmysql/#findComment-119045 Share on other sites More sharing options...
HuggieBear Posted November 3, 2006 Share Posted November 3, 2006 Use [url=http://uk.php.net/manual/en/function.htmlentities.php]htmlentities()[/url] on the text you want to put into the database, this will convert the & to &RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/26038-dealing-with-the-ampersand-character-in-phpmysql/#findComment-119047 Share on other sites More sharing options...
mark_nsx Posted November 3, 2006 Author Share Posted November 3, 2006 btw those values are gotten from a <select> list then passed to the $_REQUEST[] array, along with a bunch of other variables, then onto the handling script.. i think the script gets confused when it encounters the & character.. for instance..post.php?var1=Management & Staff&var2=Legal... Quote Link to comment https://forums.phpfreaks.com/topic/26038-dealing-with-the-ampersand-character-in-phpmysql/#findComment-119053 Share on other sites More sharing options...
HuggieBear Posted November 3, 2006 Share Posted November 3, 2006 Yes, that's exactly what's causing the problem.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/26038-dealing-with-the-ampersand-character-in-phpmysql/#findComment-119056 Share on other sites More sharing options...
mark_nsx Posted November 3, 2006 Author Share Posted November 3, 2006 i need to somehow encode the string before it gets passed.. Quote Link to comment https://forums.phpfreaks.com/topic/26038-dealing-with-the-ampersand-character-in-phpmysql/#findComment-119057 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.