Home > Backend Development > PHP Tutorial > PHP INSERT INTO插入不了数据问题

PHP INSERT INTO插入不了数据问题

WBOY
Release: 2016-06-23 14:03:59
Original
2167 people have browsed it


提交表单用INSERT INTO插入数据,但总是空白,没提示出错。请问那里有问题了?

@header("content-Type: text/html; charset=utf-8");require_once 'inc/site_config.php';require_once 'inc/db_connections.php';require_once 'inc/function.php';mysql_query('set character set "utf8"'); session_start();if($_REQUEST['action']=='postreg'){$sql_check_usr="select * from `reguser`  where `UserId`='".$_SESSION['uid']."'";$info=mysql_query($sql_check_usr);$dingdanhao=date("YmjHis").$info[UserId];$spc=$_SESSION[producelist];$slc= $_SESSION[quatity];$shouhuoren=$_POST['trusername'];$dizhi=$_POST['address'];$youbian=$_POST['phone'];$tel=$_POST['mob'];$email=$_POST['email'];if(trim($_POST['d_content'])==""){   $leaveword=""; } else{   $leaveword=$_POST['d_content'];} $xiadanren=$_SESSION['uid']; $time=date("Y-m-j H:i:s"); $total=$_SESSION[total]; $sql_add_usr="INSERT INTO onlineorder  (dingdanhao,spc,slc,UserName,address,phone,mobile,mail,yqinfo,OrderTime,UserId,total_price) VALUES ('$dingdanhao','$spc','$slc','$trusername','$address','$phone','$mob','$email','$d_content','$time','$xiadanren','$total')";mysql_query($sql_add_usr);}	
Copy after login


回复讨论(解决方案)

把SQL语句打印出来,然后到PHPMYADMIN等工具中运行SQL语句看看结果如何。
这个是常用的检查SQL正确性方法。

$info=mysql_query($sql_check_usr);
$dingdanhao=date("YmjHis").$info[UserId];
$info 是个结果资源集,$info[UserId] 这样用不对

mysql_query($sql_add_usr) or die(mysql_error());  //这样看看是否报错

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