944,008 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 740
  • PHP RSS
Sep 20th, 2008
0

Funny-crazy problem with PHP

Expand Post »
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.
Reputation Points: 8
Solved Threads: 0
Light Poster
Punkis448 is offline Offline
31 posts
since May 2008
Sep 20th, 2008
0

Re: Funny-crazy problem with PHP

Check database table. What's its collation? UTF8_*?
Last edited by PoA; Sep 20th, 2008 at 9:36 pm.
PoA
Reputation Points: 19
Solved Threads: 9
Posting Whiz in Training
PoA is offline Offline
234 posts
since Jul 2004
Sep 20th, 2008
0

Re: Funny-crazy problem with PHP

Yes all are encoded to utf8. from the database to all pages
Reputation Points: 8
Solved Threads: 0
Light Poster
Punkis448 is offline Offline
31 posts
since May 2008
Sep 20th, 2008
0

Re: Funny-crazy problem with PHP

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.
Reputation Points: 8
Solved Threads: 0
Light Poster
Punkis448 is offline Offline
31 posts
since May 2008
Sep 20th, 2008
0

Re: Funny-crazy problem with PHP

You need to convert input search data to html entities before you find in database. php.net/htmlentities
PoA
Reputation Points: 19
Solved Threads: 9
Posting Whiz in Training
PoA is offline Offline
234 posts
since Jul 2004
Sep 20th, 2008
0

Re: Funny-crazy problem with PHP

i did that.. i guess i do not know where to put it in my code.

PHP Syntax (Toggle Plain Text)
  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.
Reputation Points: 8
Solved Threads: 0
Light Poster
Punkis448 is offline Offline
31 posts
since May 2008
Aug 20th, 2011
0
Re: Funny-crazy problem with PHP
what kind f mysql server do you use???? aw regardless to the version of mysql server you can use a simple php code to solve your problem like the str_replae();
you can replace the Greek char with some ASCI code before saving it
ans when you retrieve it you can replace it back ... if you have many chars you can make a switch case it is really simple... and you can put it online as a software every string goes and comes from and to the database will be converted to some string if it's a Greek letter
Reputation Points: 10
Solved Threads: 1
Newbie Poster
mamdouh ramadan is offline Offline
9 posts
since Aug 2011

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: joomla administrator component
Next Thread in PHP Forum Timeline: Session Help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC