各位大佬,求救,我的PHP中文乱码始终无法解决。简单描述一下情况:
1、写一段很简单的代码从web端向mysql输入内容。
2、网页里的charset和mysql字符全部设置为utf8。
3、输入中文后在mysql中出现乱码。
4、反复查找网上,按部就班在连接数据库后输入mysql_query("set names utf8;");问题没有得到解决,而且会冒出Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in F:\wwwroot\processorder.php on line 61Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in F:\wwwroot\processorder.php on line 61
1 order inserted into database.的提示。
5、在php_ini里已经去掉了extension_mysql前面的;号。以下是代码:请各位大佬帮我,解决不了中文输入问题,等于是废掉了。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php
   $tireqty=$_POST['tireqty'];
   $oilqty=$_POST['oilqty'];
   $sparkqty=$_POST['sparkqty'];
   $find=$_POST['find'];
   $address=$_POST['address'];
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sam's Auto Parts - Order Results</title>
</head><body>
<h1>Sam's Auto Parts</h1>
<h2>Order Results</h2>
<?php
   if ($find=="a") {
   echo '<p>Regular Customer.</p>';
   } elseif ($find=="b") {
   echo '<p>Customer referred by TV advert.</p>';
   } elseif ($find=="c") {
   echo '<p>Customer referred by phone directory.</p>';
   } elseif ($find=="d") {
   echo '<p>Customer referred by word of mouth.</p>';
   }
   else {
   echo '<p>We do not know how this customer found us.</p>';
   }
   $totalqty=0;
   $totalqty=$tireqty+$oilqty+$sparkqty;
   echo "<p>Order Processed at ";
   echo date('H:i, jS F Y');
   echo "</p>";
   
   if ($totalqty==0)
    {echo "You didn't order anything on the previous page!<br/>";}
else
{
echo '<p>Your order is as follows:</p>';
    echo "$tireqty tires<br/>";
    echo "$oilqty bottles of oil<br/>";
    echo "$sparkqty spark plugs<br/>";
    echo "Items ordered: ".$totalqty."<br/>";

   $totalamount=0.00;
   
   define('TIREPRICE',100);
   define('OILPRICE',10);
   define('SPARKEPRICE',4);
   
   $totalamount=$tireqty*TIREPRICE+$oilqty*OILPRICE+$sparkqty*SPARKEPRICE;
   echo "Subtotal: $".number_format($totalamount,2)."<br/>";
   
   $taxrate=0.10;
   $totalamount=$totalamount*(1+$taxrate);
   echo "Toatal including tax:$".number_format($totalamount,2)."<br/>";
}
  $db=new MySQLi(localhost,root,zcd,autoparts_order);
  mysql_query("set names utf8;");
  $query="insert into orderform(tire,oil,spark,address) values('".$tireqty."','".$oilqty."','".$sparkqty."','".$address."')";
  $result=$db->query($query);
  if($result) {
  echo $db->affected_rows." "."order inserted into database.";
  } else {
  echo "An error has occured. The item was not added.";
  }
  $db->close();
?>
</body>
</html>