PHPINSERTINTO cannot insert data

Source: Internet
Author: User
PHPINSERTINTO cannot insert data
Insert into is used to INSERT data in the submitted form, but it is always blank and no error is prompted. Is there a problem?

@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);}


Reply to discussion (solution)

Print the SQL statement and run the SQL statement in PHPMYADMIN and other tools to check the result.
This is a common method to check SQL correctness.

$ Info = mysql_query ($ SQL _check_usr );
$ Dingdanhao = date ("YmjHis"). $ info [UserId];
$ Info is a result resource set. $ info [UserId] is incorrect.

Mysql_query ($ SQL _add_usr) or die (mysql_error (); // check whether an error is returned.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.