PHP录入数据库乱码
数据库编码是“utf8_bin”字段的编码也是“utf8_bin”,php向数据库录入中文时总是乱码!php文件也用文本编辑并保存为utf-8的了,问题还是没有解决。下面是代码
- PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?php require_once('../Connections/internal.php'); ?><?phpif (!function_exists("GetSQLValueString")) {function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue;}}$editFormAction = $_SERVER['PHP_SELF'];if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);}if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO discuss (a, content) VALUES (%s, %s)", GetSQLValueString($_POST['a'], "text"), GetSQLValueString($_POST['content'], "text")); mysql_select_db($database_internal, $internal); $Result1 = mysql_query($insertSQL, $internal) or die(mysql_error());}mysql_select_db($database_internal, $internal);$query_Recordset1 = "SELECT * FROM discuss";$Recordset1 = mysql_query($query_Recordset1, $internal) or die(mysql_error());$row_Recordset1 = mysql_fetch_assoc($Recordset1);$totalRows_Recordset1 = mysql_num_rows($Recordset1);?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>discuss</title></head><body><table width="100%" border="1"> <tr bgcolor="#99CC33"> <td width="8%">WHO</td> <td width="84%">在说什么</td> <td width="8%">楼</td> </tr> <? $result1 = mysql_query("SELECT * FROM discuss where id < 99 order by id ASC "); while($row1=mysql_fetch_array($result1)) {$id=trim($row1['id']);$a=trim($row1['a']);$content=trim($row1['content']); echo " <tr> <td>$a</td> <td>$content</td> <td>$id</td> </tr> "; }?></table><form action="<?php echo $editFormAction; ?>" method="POST" name="form1" id="form1"> <p> <label for="content"></label> <textarea name="content" id="content" cols="90" rows="5"></textarea> </p> 选择你的身份 <label for="a"></label> <select name="a" id="a"> <option>A</option> <option>B</option> <option>C</option> <option>D</option> </select> <p> <input type="submit" name="button" id="button" value="提交" /> </p> <input type="hidden" name="MM_insert" value="form1" /></form><p> </p><div class="aritcle_card flexRow">
<div class="artcardd flexRow">
<a class="aritcle_card_img" href="/xiazai/code/11100" title="51shop 网上商城系统"><img
src="https://img.php.cn/upload/webcode/000/000/005/176493960777129.jpg" alt="51shop 网上商城系统" onerror="this.onerror='';this.src='/static/lhimages/moren/morentu.png'" ></a>
<div class="aritcle_card_info flexColumn">
<a href="/xiazai/code/11100" title="51shop 网上商城系统">51shop 网上商城系统</a>
<p>51shop 由 PHP 语言开发, 使用快速的 MySQL 数据库保存数据 ,为中小型网站实现网上电子商务提供一个完美的解决方案.一、用户模块1. 用户注册:用户信息包括:用户ID、用户名、用户密码、性别、邮箱、省份、城市、 联系电话等信息,用户注册后不能立即使用,需由管理员激活账号,才可使用(此功能管理员可设置)2. 登录功能3. 资料修改:用户可修改除账号以后的所有资料4. 忘记密码:要求用</p>
</div>
<a href="/xiazai/code/11100" title="51shop 网上商城系统" class="aritcle_card_btn flexRow flexcenter"><b></b><span>下载</span> </a>
</div>
</div></body></html><?phpmysql_free_result($Recordset1);?><div class="clear">
</div>










