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())看下错误是什么?
Statement: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