i have the following mysql query:
SELECT user_boothid,user_id,user_fname,user_lname,user_ts,user_company,user_photo FROM se_users WHERE (user_email REGEXP 'Елена' || user_displayname REGEXP 'Елена' || user_company REGEXP 'Елена' || user_title REGEXP 'Елена' || user_fname REGEXP 'Елена' || user_lname REGEXP 'Елена') && user_eventid='15' && user_id!='799' && user_active='true' && ( user_id!=818 )
if i run this query on the console, i get the result but if i run it from the php script, don't return anything. i'm using a class to manage the DB connection and query's and is this:
function __construct($serverdb,$usernamedb,$passworddb,$namedb){
//Fixed problem when old connection (from SocialEngine) was used
//$this->linkDB=mysql_connect($serverdb,$usernamedb,$passworddb)or die("Can't Connect to DB");
$this->linkDB=mysql_connect($serverdb,$usernamedb,$passworddb,TRUE)or die("Can't Connect to DB");
mysql_query("SET character_set_results=utf8", $this->linkDB);
mb_language('uni');
mb_internal_encoding('UTF-8');
mysql_select_db($namedb,$this->linkDB)or die("Can't Select DB");
//mysql_query("set names 'utf8'",$this->linkDB);
mysql_set_charset('utf8',$this->linkDB);
}
function makeQuery($query){
mysql_query("SET character_set_client=utf8", $this->linkDB);
mysql_query("SET character_set_connection=utf8", $this->linkDB);
//mysql_query("set names 'utf8'",$this->linkDB);
mysql_set_charset('utf8',$this->linkDB);
mysql_query($query,$this->linkDB)or die(mysql_error()."Query: ".$query);
return mysql_insert_id($this->linkDB);
}
function returnQuery($query){
mysql_query("SET character_set_results=utf8", $this->linkDB);
//mysql_query("set names 'utf8'",$this->linkDB);
mysql_query("SET CHARACTER SET 'utf8'",$this->linkDB);
mysql_set_charset('utf8',$this->linkDB);
$temp=mysql_query($query,$this->linkDB)or die(mysql_error());
$num=mysql_num_rows($temp);
$rows=Array();
for($i=0;$i<$num;$i++){
$rows[$i]=mysql_fetch_assoc($temp)or die(mysql_error());
}
return $rows;
}
i tested it and the encoding seems to be ok (if i make a query with the ID, return the row with all the Russian chars as it should) but using the regexp doesn't work.
anyone can give me a hint of where to look?
Regards, Shadow.
UPDATE: this problem happen if i use LIKE or = to search also. UPDATE2: i realized that the problem is the $term var that contain the term to search, if i hardcode the value the query works, but no if i receive the value from post