db.php
<?
      $connect = MYSQL_CONNECT( "localhost", "root", "") or die("Unable to connect to MySQL server"); 
  mysql_query("SET NAMES 'utf8'"); 
   mysql_select_db( "eaglestar") or die("Unable to select database"); 
  
?>-----------------------------------------------$sql = "insert into db_news(news_name,news_content,news_pubtime,shoetype,http,yesno) values('$title','$message',now(),'$news','$http',1)";
  $result = mysql_query($sql); 
echo "aaaaaa=". $result."<br>"; //打印无值
if($result){
  echo("<script type='text/javascript'> alert('发布成功!');location.href='infomation_news.php';</script>");
}else {
  echo ($sql);
}
//如果把mysql_query("SET NAMES 'utf8'");   去掉,就可以正确的执行了。这是为什么,已经搞啊快一天了。。 

解决方案 »

  1.   


          $connect = MYSQL_CONNECT( "localhost", "root", "") or die("Unable to connect to MySQL server");     mysql_select_db( "eaglestar") or die("Unable to select database");
         mysql_query("SET NAMES 'utf8'",$connect);    //搞下来试试
    -----------------------------------------------$sql = "insert into db_news(news_name,news_content,news_pubtime,shoetype,http,yesno) values('$title','$message',now(),'$news','$http',1)";
      $result = mysql_query($sql);
    var_dump($result);exit();   //这里打印一下返回值
    if($result){
      echo(" <script type='text/javascript'> alert('发布成功!');location.href='infomation_news.php'; </script>");
    }else {
      echo ($sql);

    试试!
      

  2.   

    中邪了....   这和使用smarty框架有关系么?
      

  3.   

     header('Content-Type:text/html;charset=GB2312'); 
    你在文件头部用这句话也不行吗?
      

  4.   

    试试把一楼这里面的代码
    mysql_query("SET NAMES 'utf8'",$connect); 
    改成
    mysql_query("SET NAMES utf8",$connect);