Jump to content

need to modify a string before a mysql query is run (language issue)


Looktrne

Recommended Posts

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

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;
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.