在mysql,php中的UTF-8 chartset

时间:2017-02-09 13:05:18

标签: php mysql utf-8

我有一张UTF-8的登录表格,我现在在线搜索了一个小时,找不到任何东西。

我正在尝试将希伯来语用于我正在制作的网站,这是我现在在网上找到的内容(显然这对我不起作用)。 注意:它与英语完全一致,只有当我使用希伯来语时它才会出现以下错误:

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given

Notice: Trying to get property of non-object

PHP script我现在已经制作了(只是其中的一小部分):

$db_ip = "localhost";
                    $db_password = "";
                    $db_user = "root";
                    $db_name = "users";

                    $sql = mysqli_connect($db_ip , $db_user , $db_password);
                    if (!$sql) {

                        echo "Error: Unable to connect to the database." . PHP_EOL;
                        echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
                        echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;


                    } else {
                            mysqli_query($sql , "SET character_set_results=utf8");
                            mb_language("uni");
                            mb_internal_encoding("UTF-8");
                            mysqli_select_db($sql , "users");
                            mysqli_query($sql , "set names 'utf8'");
                            $password = $_POST['password'];
                            $emailuser = $_POST['unameemail'];
                            $password = mysqli_real_escape_string($sql , $password); 
                            $emailuser = mysqli_real_escape_string($sql , $emailuser); 

                            $pwcheck = "
                            SELECT * FROM private AS p 
                            INNER JOIN user_private_data 
                            AS c ON p.id = c.id 
                            WHERE username='$emailuser' OR email='$emailuser'"; 
                            $resultcheck = mysqli_query($sql , $pwcheck);  
                            if (mysqli_num_rows($resultcheck) > 0) {
                                $rowcheck = mysqli_fetch_array($resultcheck , MYSQLI_ASSOC);
                                $hash = $rowcheck['password']; 
                                $hash_pwd = password_verify($password , $hash);
                            } else {
                                $hash_pwd = 0;
                            }
                            if ($hash_pwd != 0) {
                                $_SESSION['username'] = $rowcheck['username']; 
                                $_SESSION['logged'] = true; 
                                header("refresh:0;url=../nahomsudaibaam.php;Content-Type: text/html; charset=utf-8");      
}

这是我的表格:

<form action="login1.php" method="post" id="loginform" accept-charset="UTF-8">
                <div style="vertical-align: top;" dir="rtl">
                    <label dir="rtl" class="labels">שם משתמש/אימייל</label>
                    <br>
                    <br>
                    <input name="unameemail" id="username" id="unamein" type="text">
                </div>
                <div style="display: block;vertical-align:top;" dir="rtl">
                    <br>
                    <label dir="rtl" class="labels">סיסמה</label>
                    <br>
                    <br>
                    <input name="password" id="passwordin" type="password">
                </div>
                <div>
                <br>
                    <br>
                    <br>
                    <input type="submit" name="submit" value="התחבר" class="btn">
                </div>
            </form>

0 个答案:

没有答案