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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.