i set a search script
but when i type something in cyrillic in the box, it searchs for it, as string of weird symbols, instead of the cyrillic ones....
how to fix that?

    Check the encoding type for both your HTML/XHTMl/XML page(s) and your database (if your search script queries a database. UTF-8 should work for you.

    If you speak Russian, like me, I assume you also have installed the Cyrillic language pack for Win32 systems if you are using Windows as your development platform.

    I would be curious to see your code if you would like to share.

      Originally posted by rachel2004
      Check the encoding type for both your HTML/XHTMl/XML page(s) and your database (if your search script queries a database. UTF-8 should work for you.

      If you speak Russian, like me, I assume you also have installed the Cyrillic language pack for Win32 systems if you are using Windows as your development platform.

      I would be curious to see your code if you would like to share.

      all pages are using charset=windows-1251
      it queries mysql database, and when i browse the tables there, the fields with cyrillic are also with weird symbols
      where i have to set this UTF-8?

      i'm using dgs search script, a little bit modified by me to fit my needs
      if u want to see the url contact me on icq, 43344647

        Originally posted by Fking
        if u want to see the url contact me on icq, 43344647

        Send me private message via this forum and I will look later.

          I'm pretty sure this would work:

          <meta http-equiv="content-type" content="text/html; charset=utf-8">

          Put this somewhere in your <head> tags.

            Originally posted by Merve
            I'm pretty sure this would work:

            <meta http-equiv="content-type" content="text/html; charset=utf-8">

            Put this somewhere in your <head> tags.

            doesn't help, it even makes all the cyrillic on the page to look wierd
            thanks anyway

              I visited your URL. What is the database you are using? MySQL? If yes, please specify the version you are using.

              Also, please post code for the "search" query you are using to search the database.

                MySQL 4.0.18-standard

                <form method="get" action="search.php" target="_self">
                <table cellspacing="0" cellpadding="0" border="0" width="100%">
                <tr>
                <td>
                <input type="text" name="q" size="25" tabindex="1">
                &nbsp;</td>
                <td>
                <input type="submit" value="Òúðñè!" tabindex="3" name="submit">

                  Please post the actual SQL statement that you are using for your query. For example:

                  $query = "SELECT foo, bar FROM etc. ... ";

                  Also, I need to know the table definition you have for the table that is queried. For example, I need to see this:

                  CREATE TABLE myTable (
                  id int not null auto_increment,
                  primary key (id),
                  name varchar (20),

                  and so on. That will help me see what your table looks like in relation to your query string.

                    the tabes...

                    CREATE TABLE movies (
                    title varchar(255) NOT NULL,
                    titlebg varchar(255) NOT NULL,
                    description text NOT NULL,
                    artists text NOT NULL,
                    artists2 text NOT NULL,
                    artists3 text NOT NULL,
                    artists4 text NOT NULL,
                    genre varchar(255) NOT NULL,
                    genre2 varchar(255) NOT NULL,
                    genre3 varchar(255) NOT NULL,
                    subs varchar(255) NOT NULL,
                    url varchar(255) NOT NULL,
                    pic varchar(255) NOT NULL,
                    size varchar(255) NOT NULL,
                    date varchar(255) NOT NULL
                    ) TYPE=MyISAM;

                    i'm not sure about the query string, maybe it's this?
                    $query = searchMySQL($db, $q, $r, $o, $s, $matchCount);

                    and, hey thanks for your time and efforts! i really appreciate that!

                      In your code, do you already have an SQL statement to use for your search engine? If this is it:

                      $query = searchMySQL($db, $q, $r, $o, $s, $matchCount);

                      then you'll need to post the code for your function searchMySQL() as well as tell me what the variables $db, $q, $r and so on all contain.

                      I was thinking more along the lines of a line in your code that looks like:

                      $sql = "SELECT column_name FROM table_name... " etc.

                      If that is what is contained in your function, then post the code for the function so I can see what you are doing.

                      Actually, if you could just post your code altogehter (but use the color highlighting features so it's not in black and white), that might be best for me to see what you are doing or have done so far.

                        function searchMySQL($db, $q, $r, $o, $s, $c) {
                                global $config;
                        
                            $server = $db['server'];
                            $port = $db['port'];
                            $username = $db['username'];
                            $password = $db['password'];
                            $database = $db['database'];
                            $tables = $db['table'];
                            $tableAssoc = $db['tableAssoc'];
                            $rfields = $db['returnField'];
                            $sfields = $db['searchField'];
                            $wildcard = strtolower($db['wildcard']);
                            $persistent = $db['persistent'];
                            $orderByDepth = $db['orderByDepth'];
                            $forceLower = $db['forceLower'];
                            $debug = $config['debug'];
                            $retVal = array();
                        
                            if ($debug)
                                    printf("-->Debug: searchMySQL()<BR>\n");
                        
                            if (!function_exists('mysql_connect')) {
                                    printf("MySQL support is not compiled into PHP.<BR>\n");
                                    return $retVal;
                            }
                        
                            if (strlen($server) < 1)
                                    $server = 'localhost';
                        
                            if ($port > 0)
                                    $server = sprintf("%s:%d", trim($server), $port);
                        
                            if ($debug)
                                    printf("-->Debug: searchMySQL() - server: '%s', username: '%s', password: '%s'<BR>\n", $server, $username, $password);
                        
                            if ($persistent)
                                    $con = @mysql_pconnect($server, $username, $password);
                            else
                                    $con = @mysql_connect($server, $username, $password);
                        
                            if (!$con) {
                                    printf("Error: Connection to MySQL server '%s' failed.<BR>\n", $server);
                                    return $retVal;
                            }
                        
                            if (!@mysql_select_db($database, $con)) {
                                    printf("Error: Connection to MySQL database '%s' failed.<BR>\n>%s: %s<BR>\n", $database, @mysql_errno($con), @mysql_error($con));
                                    return $retVal;
                            }
                        
                            $statement = 'SELECT ';
                            $orderBy = ' ORDER BY ';
                        
                            if ($s > 0 && $r > 0) {
                                    $limit = ' LIMIT ';
                                    if ($o > 0)
                                            $limit .= sprintf('%d,%d', $o, $r);
                                    else
                                            $limit .= $r - ($c % $r);
                            }
                        
                            $i = 0;
                            reset($rfields);
                            while (list(, $entry) = each($rfields)) {
                                    $statement .= $entry;
                                    if ($i < $orderByDepth || $orderByDepth < 0)
                                            $orderBy .= $entry;
                                    $i++;
                                    if ($i < count($rfields)) {
                                            $statement .= ', ';
                                            if ($i < $orderByDepth || $orderByDepth < 0)
                                                    $orderBy .= ', ';
                                    }
                            }
                        
                            $statement .= ' FROM ';
                        
                            $i = 0;
                            reset($tables);
                            while (list(, $entry) = each($tables)) {
                                    $i++;
                                    $statement .= $entry;
                                    if ($i < count($tables))
                                            $statement .= ', ';
                            }
                        
                            $statement .= ' WHERE ';
                        
                            if (strlen($tableAssoc) > 0)
                                    $statement .= $tableAssoc . ' AND (';
                        
                            $i = 0;
                            reset($sfields);
                            while (list(, $entry) = each($sfields)) {
                                    $i++;
                                    if ($forceLower) {
                                            $statement .= 'LOWER(' . $entry . ')';
                                            $q = strtolower($q);
                                    } else {
                                            $statement .= $entry;
                                    }
                                    if (!strcmp($wildcard, 'none')) {
                                            $statement .= ' = \'';
                                    } else {
                                            $statement .= ' LIKE \'';
                                    }
                                    if (!strcmp($wildcard, 'left') || (strcmp($wildcard, 'right') && strcmp($wildcard, 'none')))
                                            $statement .= '%';
                                    $statement .= $q;
                                    if (!strcmp($wildcard, 'right') || (strcmp($wildcard, 'left') && strcmp($wildcard, 'none')))
                                            $statement .= '%';
                                    $statement .= '\'';
                                    if ($i < count($sfields))
                                            $statement .= ' OR ';
                            }
                        
                            if (strlen($tableAssoc) > 0)
                                    $statement .= ') ';
                        
                            if ($orderByDepth != 0)
                                    $statement .= $orderBy;
                        
                            if ($limit)
                                    $statement .= $limit;
                        
                            if ($debug) {
                                    printf("-->Debug: searchMySQL() - MySQL statement: %s<BR>\n", $statement);
                                    flush();
                            }
                        
                            $query = @mysql_query($statement, $con);
                            if (!$query && $forceLower) {
                                    if ($debug) {
                                            printf("-->Debug: searchMySQL() - Statement failed using LOWER(), now attempting with LCASE().<BR>\n-->Debug: searchMySQL() - %s: %s<BR>\n", mysql_errno($con), @mysql_error($con));
                                    }
                                    str_replace('LOWER', 'LCASE', $statement);
                                    $query = @mysql_query($statement, $con);
                            }
                            if (!$query) {
                                    printf("Error: MySQL query '%s' failed.<BR>\n>%s: %s<BR>\n", $statement, @mysql_errno($con), @mysql_error($con));
                                    return $retVal;
                            }
                        
                            $width = count($rfields);
                            for ($row = 0; $row < $o - ($c % $r); $row++) /* Pad out results. We need a real fix. */
                                    $retVal[$row][0] = 0;
                            while ($line = mysql_fetch_row($query)) {
                                    for($i = 0; $i < $width; $i++) {
                                            $retVal[$row][$rfields[$i]] = $line[$i];
                                    }
                                    $row++;
                            }
                        
                            if (!$db['persistent'])
                                    mysql_close($con);
                        
                            return $retVal;
                        

                        this is the function, it does not allow me to post the whole code because there is limit on the characters
                        anyway i hope this is enough, if not, will split the whole code in few posts

                          Write a Reply...