Home > Backend Development > PHP Tutorial > PHP链接MySQL有关问题。新手

PHP链接MySQL有关问题。新手

WBOY
Release: 2016-06-13 11:55:42
Original
808 people have browsed it

PHP链接MySQL问题。新手求助


    
    


if(@$_POST["submit"]){
    $id = $_POST["id"];
    $name = $_POST["name"];
    $age = $_POST["age"];
    $tel = $_POST["tel"];
    $address = $_POST["address"];



    $conn = @mysql_connect("localhost","root","ROOT") or die("数据库连接超时,请稍后再试!");
    mysql_select_db("test",$conn);
    mysql_query("set names 'utf8'");

    $sql = "select * from `student`";
    $sql = "INSERT INTO `student`(`id`, `name`, `age`, `tel`, `address`) VALUES ('$id','$name','$age','$tel','$address')";
    mysql_query($sql);
}
?>



    编  号:  

    姓  名:  

    年  龄:  

    电  话:  

    地  址:  

    
















这是我建的数据表、  进入页面添加数据生成再刷新数据表内容是空的。是什么问题呢?


------解决方案--------------------
编码问题 插入的文字编码和数据库的编码不一致
------解决方案--------------------
mysql_query($sql) or die(mysql_error())看下错误是什么?
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template