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) 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(). 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' 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 & 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 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. 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
Archived
This topic is now archived and is closed to further replies.