php接收html页面提交过来的值,能接收的到,但是进不去数据库

html页面------------------------------------------------------<HTML><HEAD><TITLE>添加学生成绩... html页面------------------------------------------------------<HTML> <HEAD> <TITLE>添加学生成绩界面</TITLE> <meta charset="utf-8"> </HEAD> <BODY> <h1>添加学生界面</h1> <script type="text/javascript"></script> <form action="http://localhost/mysql/insertStudent.php" method="post"> 学生编号<input type="text" name="stuId"><br> 学生姓名<input type="text" name="stuName"><br> 语文成绩<input type="text" name="stuChinese"><br> 数学成绩<input type="text" name="stuMath"><br> 英语成绩<input type="text" name="stuEnglish"><br> <input type="submit" value="添加成绩"> </form></BODY> </HTML>php页面---------------------------------------------------------<?php header("Content-type:text/html;charset=utf-8"); $stuId=$_POST['stuId']; $stuName=$_POST['stuName']; $stuChinese=$_POST['stuChinese']; $stuMath=$_POST['stuMath']; $stuEnglish=$_POST['stuEnglish']; echo $stuMath; $con=mysql_connect('localhost','root',''); if(!$con){ echo '连接失败'; exit; }else{ echo '连接成功'; } mysql_select_db('db_student'); $sql = "INSERT INTO table_student VALUES($stuId,'$stuName',$stuChinese,$stuMath,$stuEnglish)"; // $sql = "INSERT INTO table_student(id,name,chinses,math,english)VALUES($stuId,'$stuName',$stuChinese,$stuMath,$stuEnglish)"; echo $sql; $is_ok = mysql_query($sql); if($is_ok == true){ echo '添加成功'; }else{ echo '添加失败'; }?> 展开
 我来答
长城郭靖
2017-11-07 · TA获得超过729个赞
知道小有建树答主
回答量:1090
采纳率:47%
帮助的人:378万
展开全部
mysql_connect即将被移除,换一个试试,插入语句没写时间表字段。
更多追问追答
追问
前辈,我现在数据可以正常录入了,不过是只能录入数字。那个name只要放中文,就不能成功进入数据库
追答
那就是数据类型不匹配了?
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式