Funny-crazy problem with PHP

Reply

Join Date: May 2008
Posts: 31
Reputation: Punkis448 is an unknown quantity at this point 
Solved Threads: 0
Punkis448 Punkis448 is offline Offline
Light Poster

Funny-crazy problem with PHP

 
0
  #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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 234
Reputation: PoA is an unknown quantity at this point 
Solved Threads: 8
PoA PoA is offline Offline
Posting Whiz in Training

Re: Funny-crazy problem with PHP

 
0
  #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 Quick reply to this message  
Join Date: May 2008
Posts: 31
Reputation: Punkis448 is an unknown quantity at this point 
Solved Threads: 0
Punkis448 Punkis448 is offline Offline
Light Poster

Re: Funny-crazy problem with PHP

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

Re: Funny-crazy problem with PHP

 
0
  #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 Quick reply to this message  
Join Date: Jul 2004
Posts: 234
Reputation: PoA is an unknown quantity at this point 
Solved Threads: 8
PoA PoA is offline Offline
Posting Whiz in Training

Re: Funny-crazy problem with PHP

 
0
  #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 Quick reply to this message  
Join Date: May 2008
Posts: 31
Reputation: Punkis448 is an unknown quantity at this point 
Solved Threads: 0
Punkis448 Punkis448 is offline Offline
Light Poster

Re: Funny-crazy problem with PHP

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

  1. /* generate query syntax for searching in auction */
  2. $search_words = explode (" ", $qquery);
  3.  
  4. /* query part 1 */
  5. $qp1 = "";
  6. $qp = "";
  7. $qp1 = htmlentities($qp1);
  8. $qp1 .=
  9. " (title LIKE '%".
  10. addslashes($qquery).
  11. "%' OR id=".intval($q).") ";
  12.  
  13. $qp .= " (cat_name LIKE '%".addslashes($qquery)."%') ";
  14.  
  15. $addOR = true;
  16. while ( list(,$val) = each($search_words) ) {
  17. $val = ereg_replace("%","\\%",$val);
  18. $val = ereg_replace("_","\\_",$val);
  19. if ($addOR) {
  20. $qp1 .= " AND ";
  21. $qp .= " AND ";
  22. }
  23. $addOR = true;
  24.  
  25. $qp1 .=
  26. " (title LIKE '%".
  27. addslashes($val).
  28. "%') ";
  29.  
  30. $qp .= "(cat_name LIKE '%".addslashes($qquery)."%') ";
  31. }
  32. // die($qp1);
  33. // print $qp."<BR>";
  34.  
  35. $sql_count = "SELECT count(*) FROM PHPAUCTIONXL_auctions
  36. WHERE ( $qp1 )
  37. AND ( closed='0')
  38. AND ( suspended='0')
  39. AND private='n'
  40. AND starts<=".$NOW."
  41. ORDER BY buy_now";
  42. $sql = "SELECT * FROM PHPAUCTIONXL_auctions
  43. WHERE ( $qp1 )
  44. AND ( closed='0')
  45. AND ( suspended ='0')
  46. AND private='n'
  47. AND starts<=".$NOW."
  48. ORDER BY buy_now";
Last edited by Punkis448; Sep 20th, 2008 at 10:45 pm.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC