How to insert an hebrew value into a mysql db in php

后端 未结 8 1183
温柔的废话
温柔的废话 2020-12-10 15:30

I\'m trying to insert an hebrew value into my mysql db, instead of hebrew the values looks like that.

שדגשדכעשד

8条回答
  •  误落风尘
    2020-12-10 16:15

    I think I figure it out: here's my code:

    $conn = mysqli_connect($dbserver,$dbuser,$dbpwd,$dbname);
    
    if (mysqli_connect_errno()){
        printf("Connection failed: %s\n" , mysqli_connect_errno());
        exit();
    }
    
    printf("Initial character set: %s\n", mysqli_character_set_name($conn));
    
    /* change character set to utf8 */
    if (!mysqli_set_charset($conn, "hebrew")) {
        printf("Error loading character set hebrew: %s\n", mysqli_error($conn));
        exit();
    } else {
        printf("Current character set: %s\n", mysqli_character_set_name($conn));
    }
    

提交回复
热议问题