Issue with PHP MySQL and insert into UTF-8

前端 未结 1 1045
逝去的感伤
逝去的感伤 2021-01-23 15:47

I have a problem with php & mysql, insert to database using utf-8. first file: addsite:



        
相关标签:
1条回答
  • 2021-01-23 15:52

    add this line:

        mysql_query("SET NAMES 'utf8'");
    
    Like this
    
    if(!(@mysql_connect("$host","$user","$pass") && @mysql_select_db("$tablename"))) {
        ?>
        <html>
        MSQL ERROR
        <?
        exit;
    }
    else{
        mysql_query("SET NAMES 'utf8'");
    }
    

    Also: - Add meta charset to the form page

    <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
    

    or HTML5

     <meta charset='utf-8'> 
    
    0 讨论(0)
提交回复
热议问题