viion Posted February 18, 2009 Share Posted February 18, 2009 What is the function to find a term and replace it. I need to find '&' and replace it with 'and' whenever someone puts that in to the name field. (company name) Quote Link to comment https://forums.phpfreaks.com/topic/145806-find-and-replace-when-doing-_post/ Share on other sites More sharing options...
Maq Posted February 18, 2009 Share Posted February 18, 2009 Use str_replace(). Quote Link to comment https://forums.phpfreaks.com/topic/145806-find-and-replace-when-doing-_post/#findComment-765534 Share on other sites More sharing options...
viion Posted February 18, 2009 Author Share Posted February 18, 2009 Nut working =( Trying ereg_replace because the str_replace seemed, weird. $salon_name = htmlspecialchars(mysql_real_escape_string($_POST['salon_name'])); $salon_name_clean = ereg_replace('&', 'and', $salon_name); SQL $sql = "INSERT INTO salon_data SET salon_name='$salon_name_clean' Quote Link to comment https://forums.phpfreaks.com/topic/145806-find-and-replace-when-doing-_post/#findComment-765541 Share on other sites More sharing options...
Maq Posted February 18, 2009 Share Posted February 18, 2009 You have to do the string sanitizing (htmlspecialcharacters and mysql_real_escape_string) after you replace the ereg_replace(). The reason for this is because the htmlspecialcharacters will convert '&' to & Quote Link to comment https://forums.phpfreaks.com/topic/145806-find-and-replace-when-doing-_post/#findComment-765558 Share on other sites More sharing options...
viion Posted February 18, 2009 Author Share Posted February 18, 2009 Okay that worked =D Quote Link to comment https://forums.phpfreaks.com/topic/145806-find-and-replace-when-doing-_post/#findComment-765585 Share on other sites More sharing options...
Maq Posted February 18, 2009 Share Posted February 18, 2009 Okay that worked =D Awesome, mark as [sOLVED] if that's the case. Quote Link to comment https://forums.phpfreaks.com/topic/145806-find-and-replace-when-doing-_post/#findComment-765603 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.