Looktrne Posted May 28, 2008 Share Posted May 28, 2008 I am trying to help out a friend with a simalar dating site to my own the problem is they added thai language to many of the fields and does not work well with the script I need to strip the thai language from the querry for example I need the string SELECT free_trial FROM dt_genders WHERE name='Male / ชาย' to become SELECT free_trial FROM dt_genders WHERE name='Male' it needs to strip any data found in the string starting with / and ending with ' and also should remove the space in front of the / this string can have multiple instances with the / ชาย' so it needs to check the entire string for as many duplicates as needed.... this string is passed to a mysql querry and I need it stripped of the / thai language please give some advise on the best way to do this without affecting speed so much some of the strings may not have the / at all so I think a quick check of the string for /'s first would speed things up before running the modification to the string... the function that gets the string is here function q($q_str) { global $db_name // I need to take $q_str and perform the above check here before the query $r = mysql($db_name, $q_str); return $r; } any help on this is greatly appreciated tia Paul Link to comment https://forums.phpfreaks.com/topic/107657-need-to-modify-a-string-before-a-mysql-query-is-run-language-issue/ Share on other sites More sharing options...
Psycho Posted May 28, 2008 Share Posted May 28, 2008 This appears to work. It worked for strings with multiple instances, but I hav enot done extensive testing. <?php function q($q_str) { global $db_name $q_str = eregi_replace(" / [^']*", '', $q_str); $r = mysql($db_name, $q_str); return $r; } ?> Link to comment https://forums.phpfreaks.com/topic/107657-need-to-modify-a-string-before-a-mysql-query-is-run-language-issue/#findComment-551875 Share on other sites More sharing options...
Looktrne Posted May 28, 2008 Author Share Posted May 28, 2008 Thank you for this I will test it out now Paul Link to comment https://forums.phpfreaks.com/topic/107657-need-to-modify-a-string-before-a-mysql-query-is-run-language-issue/#findComment-552053 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.