Search script locally works internet does not

Hello all,

I am missing something due to to much partying I guess, but I have a small search script that works locally using wamp but when I throw it out on the internet, it works with latin characters but does not with Greek even though everything is xhtml and utf-8.

What am I overlooking or not remembering?

anything
some encoding issue may be.
debugging can give you answer

first of all define “not working”, with examples

Hello Shrapnel_N5,

Not working maybe too extreme. The search is working with latin characters, e.g. if I type New York it works, but when I type Γρηγορίου it does not return values for the search.

On my local wamp the script works correctly and the database table is exactly the same and set to utf-8 in both cases.

I have just looked at phpinfo to compare settings for multibyte and they are the same.

Html and encoding is xhtml utf-8.

Thanks for responding.

do you set client encoding in your php scripts? set names query for example?
What did you do to you ensure that your data and database encoding set to utf8?

Here is most of my script:



    ini_set('display_errors','On'); 
    error_reporting(E_ALL | E_STRICT);

    mb_internal_encoding("UTF-8");
    ini_set('auto_detect_line_endings', 1);
    date_default_timezone_set('Europe/Athens');


        test_db_connect() 
            or die ("Δεν είναι δυνατή η σύνδεση με τον διακομιστή, παρακαλώ ξανά δοκιμάστε σε άλλη στιγμή.
                    <br /> Cannot connect to server, Please try again at another time.<br /> \
");
        mysql_query("SET NAMES 'UTF8'");
        mysql_query("SET CHARACTER SET 'utf8'");

        print "<form action=".$_SERVER['PHP_SELF']." method=\\"post\\">\
";
        print "<td>\
";
        print "<input name=\\"title\\" size=\\"60\\" maxlength=\\"200\\"><br />\
";
        print "</td>\
";
        print "</tr><tr>\
";
        print "<td colspan=\\"2\\">&nbsp;</td>\
";  // <hr>draw line
        print "</tr><tr>\
";
        print "<td colspan=\\"2\\" align=\\"center\\">\
";
        print "<input type=\\"submit\\" name=\\"phrase\\" value=\\"- Search -\\" />";

        // INPUT ERROR CHECKING BEGINS HERE
        // alternate through variables, check for empty, validate
       //-----------------------------------------------------------------------
        if (!get_magic_quotes_gpc()) {
            foreach ($_POST as $key => $value) {
                // Assign to $temp and trim spaces if not array 
                $_POST[$value] = is_array($value) ? $value : addslashes(trim($value));
            } // end foreach
        } else {
            foreach ($_POST as $key => $value) {
                // Assign to $temp and trim spaces if not array 
                $_POST[$value] = is_array($value) ? $value : trim($value);
            } // end foreach
        } // end if (!get_magic_quotes_gpc

        //This stops SQL Injection in POST vars
        foreach ($_POST as $key => $value) {
            $_POST[$key] = mysql_real_escape_string($value);
        }
        
        //This stops SQL Injection in GET vars
        foreach ($_GET as $key => $value) {
            $_GET[$key] = mysql_real_escape_string($value);
        }

        $keyword = $_POST['title'];
            if (empty($keyword)) { 
                print "<br />\
";
                print "<div align='center' class='red'>";
                print "No keyword was entered to search for a book!"; 
                print "<br /><br />\
";
                gobackpage();
                print "</div>";
                print "<br /><br />\
";
                die;
                ?>
                    </body>
                    </html>
                <?
                die;
                }

        // regular search
        $select = "SELECT * FROM $db_name.$table_name 
                    WHERE ( subject     LIKE '%$keyword%' OR 
                            author         LIKE '%$keyword%' OR 
                            isbn         LIKE '%$keyword%' OR 
                            city         LIKE '%$keyword%' OR 
                            title         LIKE '%$keyword%' OR 
                            owner         LIKE '%$keyword%'
                            )";
        $result = mysql_query($select) or die($errorinfo);

        // display record
        disp_recs();


well you have SET NAMES set.
here are some suggestions I posted before, on how to check if your database set up properly
you have to check also if your data in the database has proper encoding.
if you just select it, without search - does it display properly?

The database appears to be correctly displaying the data.

Here is a link for you to try it. Type New York and you should see the output display the information that it has in both English and Greek.

http://www.enosismyrneon.gr/ext/online-library-search.html

I assume that you have seen the output in both languages?

I found the error. When I created the database for this, I forgot to change the encoding to general utf-8. As I checked the table encoding and found that it was correctly set to utf-8 I suddenly realized that I forgot to check the database.

Solved!