User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,272 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,421 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 262 | Replies: 5
Reply
Join Date: May 2008
Posts: 23
Reputation: Punkis448 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Punkis448 Punkis448 is offline Offline
Newbie Poster

Funny-crazy problem with PHP

  #1  
Sep 20th, 2008
Hi again.

I have a project that gets from mysql the data that i search.
Until 10 minutes ago, the results could not display me correctly the Greek characters from mysql.
The search system searches the title of the item which contains English and Greek characters.

I solve this problem with this :
I use notepad for any encoding i do between ansi, unicode and utf8.
I wrote into notepad the title in English and for the Greek letters i wrote them in HTML encoded characters and i saved it as ANSI.

On phpmyadmin I uploaded the file choosing utf8 for Character set of the file and ANSI for sql compatibility.

i searched for that English word i wrote in the title and displayed to me the result WITH GREEK LETTERS correctly.
This is the only way to display Greek letters. I tried everything.

The problem is :
When i searched using that Greek letters that i wrote in the title the result showed me nothing. Then i searched again using the HTML encoded characters i used for that title and i got the result with Greek letters!

Having in mind that with HTML encoded characters the system found me the result, I guess there must be a line that it will convert the Greek characters to HTML encoded characters before it gives me the results.

Anyone knows anything about this?
Last edited by Punkis448 : Sep 20th, 2008 at 6:04 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2004
Posts: 226
Reputation: PoA is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 6
PoA PoA is offline Offline
Posting Whiz in Training

Re: Funny-crazy problem with PHP

  #2  
Sep 20th, 2008
Check database table. What's its collation? UTF8_*?
Last edited by PoA : Sep 20th, 2008 at 9:36 pm.
Reply With Quote  
Join Date: May 2008
Posts: 23
Reputation: Punkis448 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Punkis448 Punkis448 is offline Offline
Newbie Poster

Re: Funny-crazy problem with PHP

  #3  
Sep 20th, 2008
Yes all are encoded to utf8. from the database to all pages
Reply With Quote  
Join Date: May 2008
Posts: 23
Reputation: Punkis448 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Punkis448 Punkis448 is offline Offline
Newbie Poster

Re: Funny-crazy problem with PHP

  #4  
Sep 20th, 2008
My greek data is written in the database using the decimal format http://htmlhelp.com/reference/html40...s/symbols.html

The only way to get the results displayed is when i search with those decimal codes.

I want to convert the greek letters that i write in the searchbox to those decimal codes before it gives me the results, with this way i will get the correct search results.
Reply With Quote  
Join Date: Jul 2004
Posts: 226
Reputation: PoA is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 6
PoA PoA is offline Offline
Posting Whiz in Training

Re: Funny-crazy problem with PHP

  #5  
Sep 20th, 2008
You need to convert input search data to html entities before you find in database. php.net/htmlentities
Reply With Quote  
Join Date: May 2008
Posts: 23
Reputation: Punkis448 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Punkis448 Punkis448 is offline Offline
Newbie Poster

Re: Funny-crazy problem with PHP

  #6  
Sep 20th, 2008
i did that.. i guess i do not know where to put it in my code.

/* generate query syntax for searching in auction */
$search_words = explode (" ", $qquery);

/* query part 1 */
$qp1 = "";
$qp = "";
$qp1 = htmlentities($qp1);
$qp1 .=
" (title LIKE '%".
addslashes($qquery).
"%' OR id=".intval($q).")  ";

$qp .= " (cat_name LIKE '%".addslashes($qquery)."%') ";

$addOR = true;
while ( list(,$val) = each($search_words) ) {
	$val = ereg_replace("%","\\%",$val);
	$val = ereg_replace("_","\\_",$val);
	if ($addOR) {
		$qp1 .= " AND ";
		$qp .= " AND ";
	}
	$addOR = true;
	
	$qp1 .=
	" (title LIKE '%".
	addslashes($val).
	"%')  ";
	
	$qp .= "(cat_name LIKE '%".addslashes($qquery)."%') ";
}
//	die($qp1);
//	print $qp."<BR>";

$sql_count = "SELECT count(*) FROM PHPAUCTIONXL_auctions 
				WHERE ( $qp1 ) 
				AND ( closed='0')  
				AND ( suspended='0') 
				AND private='n' 
				AND	starts<=".$NOW." 
				ORDER BY buy_now";
$sql = "SELECT * FROM PHPAUCTIONXL_auctions 
			WHERE ( $qp1 ) 
			AND ( closed='0')  
			AND ( suspended ='0') 
			AND private='n' 
			AND	starts<=".$NOW." 
			ORDER BY buy_now";
Last edited by Punkis448 : Sep 20th, 2008 at 10:45 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the PHP Forum

All times are GMT -4. The time now is 6:30 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC