<?php
header("Content-Type:text/html;charset=UTF-8");
$username = $_POST["username"];
$contact = $_POST["contact"];
$message = $_POST["message"];
$link = mysql_connect('localhost','root','###');
if (!$link) {
die('could not connect :' .mysql_error());
}
mysql_select_db('notebook',$link);
mysql_query("insert into info (username,contact,dt,message) values ($username,$contact,now(),$message)",$link);?>
我的html php mysql 都是utf8而且可以在命令提示符下可以用insert插入进去.为什么用mysql_query()不行?谢谢大家

解决方案 »

  1.   

    字符串
    "insert into info (username,contact,dt,message) values ('$username','$contact',now(),'$message')"
      

  2.   


    header("Content-Type:text/html;charset=UTF-8");
    $username = $_POST["username"];
    $contact = $_POST["contact"];
    $message = $_POST["message"];
    $link = mysql_connect('localhost','root','###');
    mysql_quer('Set namea utf8',$link);
    if (!$link) {
        die('could not connect :' .mysql_error());    
    }
    mysql_select_db('notebook',$link);
    mysql_query("insert into info (username,contact,dt,message) values ('$username','$contact',now(),'$message')",$link);
      

  3.   

    mysql_quer('Set namea utf8',$link);
    少个y =>mysql_query('Set namea utf8',$link);
      

  4.   

    谢谢两为朋友,可以了,还有个问题,为什么我插如中文的时候 显示乱码,UTF8不支持 中文吗我编码很统一的
      

  5.   

    names
      

  6.   

    检查文件是不是utf8编码格式.
      

  7.   

    修改不了,最新的windows命令行也不支持utf8,包括power shell也不行
      

  8.   

    ok 了  谢谢@Siramizu  很有耐心同时感谢其他两位朋友