my supermarket error

一、PHP实现添加mysql数据时,若是字段中含有中文,刷新时php不会报错,数据不会添加到数据库?php

缘由:Incorrect string value: '\xD6\xD0\xB9\xFA\xB1\xEA...' for column 'VARIABLE_VALUE' at row 1html

         一、自增的话,能够省略字段。mysql

         二、 典型的字符编码不一致问题jquery

解决:show variables like '%char%';show create table tbname;  查看字符集是否一致。ajax

        重要在con链接数据库设置:mysql_select_db("dch_db",$con);
                                               mysql_query("set names gb2312");sql

        请求PHP 页:<meta http-equiv="Content-Type" content="text/html; charset=gdk" />数据库

 

<?php
 $con=mysql_connect("localhost","root","123456");
 if(!$con){
 echo "conection fail!".mysql_error();
 }
 mysql_select_db("dch_db",$con);
 mysql_query("set names gb2312");
?>session

<?php
 session_start();
 include_once("conn.php");
 //echo $_REQUEST[user];
?>post

 二、要求对数据库的用户密码加密?学习

解决:$pass = $_POST[pass];
   //对密码MD5加密
    $pass = md5($pass);
$sql="select count(*) from tb_user where username='".$name."' and password='".$pass."' and display='管理员'";
//执行sql语句
$result=mysql_query($sql,$link);
数据字符长度设密码长度为32,

注册:<?php
if ( $_POST["submit"] <> "" )
{
include("config.php");
$pass = isset($_POST['password']) ? $_POST['password'] : '';
echo $md5_password=md5($pass . ALL_PS);
$sql="insert into user_list (id,m_id,username,password)
    values (null,'2','".$_POST["username"]."','".$md5_password."')";
   mysql_query($sql);
}
?>
<p>sign up</p>
<form action="" method ="post">
user:<input type="text" name="username"  /><br/><br />
passward:<input type="text" name="password" /><br /><br />
<input type="submit" name ="submit" value ="signup" />
</form>

 3ajax jquery 学习路径:http://hi.baidu.com/yflife/item/9655f50e2301dbca74cd3c9d 

相关文章
相关标签/搜索