Get var not working with special characters

This is a discussion on "Get var not working with special characters" within the PHP Forum section. This forum, and the thread "Get var not working with special characters are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Mar 30th, 2008, 22:35
Junior Member
Join Date: Jan 2008
Location: Reykjavik
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Get var not working with special characters

Hi, I need some help with my alphabet index search...
The index search works well and does what it's supposed to, except for when it comes to special native characters. Then is either displays a wrong result or no result at all (with no errors).

Everything is set to the charset UTF8:
My database, the database table and the search page containing the PHP code.

When a special native character is selected in the alphabet search, the search returns consistent results. But not correct results.

A demo would help describe the issue better:
There is only ONE entry in my table that starts with the letter Á (A with a coma on top).
When the following letters are selected in the alphabet search [ A, Á, Ð, Í and Ý] they give results for that ONE entry that starts with the Á. character). NOT JUST THE SEARCH FOR "Á"

How can I fix this?

Here is that pages relevant code:
PHP: Select all

<? 
session_start
(); 
include(
"database.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Alpabet search</title>
</head>
<body>

<!-- When the following link is pressed, the PHP shows reults -->
<a href="search.php?var=Á" target="_self">Á</a>

<?php    
                 
if ( isset( $_GET['var'] ) )
{
    
$query "SELECT * FROM table WHERE column LIKE '"$_GET['var'] ."%' ORDER BY column ASC";

    
$numresults=mysql_query($query);
    
$numrows=mysql_num_rows($numresults);

    
// If no results:
    
if ($numrows == 0)
    {
    echo 
"No results that start with ";
    echo 
""$_GET['var'] .""
    }
      
    
// Get results
    
$q .= " limit $s,$limit";
    
$result mysql_query($query) or die("Couldn't execute query");
    
    
// While results, print:
    
while ($rowmysql_fetch_array($result))
    {
        
$name $row["Name"];
                      
        echo 
"Results for letter:&nbsp;";
        echo 
""$_GET['var'] ."<br /><br />";
        
        echo 
"$name<br />";
        
$count++ ;
      } 
// End while loop
// End IF
?>
</body>
</html>
I've tried adding COLLATE UTF8_icelandic_ci to the query.
I've also tried adding mysql_real_escape_string() to the $name string in the while loop. But I've had no luck.
Any help would be great as this is the only thing left before publishing my new site.
Reply With Quote

Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
fgetcsv problem with special characters pwbiggs PHP Forum 1 Apr 27th, 2008 19:25
Read First 3 characters and last 4 characters of string JustinStudios PHP Forum 2 Apr 4th, 2008 00:01
Special Day Invitations GTrotter Free Web Site Critique 6 Feb 20th, 2008 15:16
Cannot Submit Special Characters from Input Fields sboot ASP.NET Forum 1 Aug 30th, 2006 16:08
using special font skyfire400 Web Page Design 2 Mar 1st, 2006 00:47


All times are GMT. The time now is 20:39.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43