简体   繁体   English

为什么无法在phpmyadmin中插入行?

[英]How come I can't insert a row in phpmyadmin?

The problem I'm experiencing is the post is working fine and I echo all of them. 我遇到的问题是帖子运行正常,我对所有这些都进行了回应。 There is no error but when I check if inserted to the database, none of the have appeared. 没有错误,但是当我检查是否已插入数据库时​​,都没有出现。 Here is the code I have written: 这是我编写的代码:

<?php
/* this area is the saving code for the item and description of the pr form */

include("db.php");
$userlogs = mysql_query("SELECT * FROM pr_head ORDER BY rfq_raw_no DESC");
if ($outing = mysql_fetch_array($userlogs)) {
    $rfq_raw_no_out = $outing['rfq_raw_no'] + 1;
}


$RFQ_date_out = $_POST['RFQ_date_in'];
$Vendor_Code_out = $_POST['Vendor_Code_in'];
$Vendor_Name_out = $_POST['Vendor_Name_in'];
$Vendor_Adress_out = $_POST['Vendor_Adress_in'];
$Email_Adress_out = $_POST['Email_Adress_in'];
$Tel_No_out = $_POST['Tel_No_in'];
$ATTENTION_out = $_POST['ATTENTION_in'];
$RFQ_NO_out = $_POST['RFQ_NO_in'];
$DEADLINE_out = $_POST['DEADLINE_in'];
$Prepared_By_out = $_POST['Prepared_By_in'];
$Position_out = $_POST['Position_in'];



mysql_query("INSERT INTO `pr_head`(`RFQ_date`, `Vendor_Code`, `Vendor_Name`, `Vendor_Adress`, `Email_Adress`, `Tel_No`, `ATTENTION`, `RFQ_NO`, `DEADLINE`, `rfq_raw_no`, `Prepared_By`, `Position`) 
                VALUES ([$RFQ_date_out],[$Vendor_Code_out],[$Vendor_Name_out],[$Vendor_Adress_out],[$Email_Adress_out],[$Tel_No_out],[$ATTENTION_out],[$RFQ_NO_out],[$DEADLINE_out],[$rfq_raw_no_out],[$Prepared_By_out],[$Position_out])");
?>

You are inserting a row in an incorrect way. 您以不正确的方式插入行。 You have to enclose your values in a quotes to make it work. 您必须将值括在引号中以使其起作用。 It should be like this VALUES ('$value1') . 它应该像这样VALUES ('$value1') Change your insert query and use this query to insert it 更改您的插入查询并使用此查询将其插入

mysql_query("INSERT INTO `pr_head`(`RFQ_date`, `Vendor_Code`, `Vendor_Name`, `Vendor_Adress`, `Email_Adress`, `Tel_No`, `ATTENTION`, `RFQ_NO`, `DEADLINE`, `rfq_raw_no`, `Prepared_By`, `Position`) 
            VALUES ('$RFQ_date_out','$Vendor_Code_out','$Vendor_Name_out','$Vendor_Adress_out','$Email_Adress_out','$Tel_No_out','$ATTENTION_out','$RFQ_NO_out','$DEADLINE_out','$rfq_raw_no_out','$Prepared_By_out','$Position_out')");

Change your query and try like this 更改查询并尝试这样

 mysql_query("INSERT INTO `pr_head`(`RFQ_date`, `Vendor_Code`, `Vendor_Name`, `Vendor_Adress`, `Email_Adress`, `Tel_No`, `ATTENTION`, `RFQ_NO`, `DEADLINE`, `rfq_raw_no`, `Prepared_By`, `Position`) 
            VALUES ('$RFQ_date_out','$Vendor_Code_out','$Vendor_Name_out','$Vendor_Adress_out','$Email_Adress_out','$Tel_No_out','$ATTENTION_out','$RFQ_NO_out','$DEADLINE_out','$rfq_raw_no_out','$Prepared_By_out','$Position_out')"); 

Because you need to enclose string values in the query in quotes. 因为您需要在查询中将字符串值括在引号中。

mysql_query("INSERT INTO `pr_head`(`RFQ_date`, `Vendor_Code`, `Vendor_Name`, `Vendor_Adress`, `Email_Adress`, `Tel_No`, `ATTENTION`, `RFQ_NO`, `DEADLINE`, `rfq_raw_no`, `Prepared_By`, `Position`) 
            VALUES ($RFQ_date_out,$Vendor_Code_out,$Vendor_Name_out,$Vendor_Adress_out,$Email_Adress_out,$Tel_No_out,$ATTENTION_out,$RFQ_NO_out,$DEADLINE_out,$rfq_raw_no_out,$Prepared_By_out,$Position_out)");

[] brackets, why?? []中括号,为什么?

Try this code:
mysql_query("INSERT INTO `pr_head` SET `RFQ_date`='$RFQ_date_out', `Vendor_Code`='$Vendor_Code_out', `Vendor_Name`='$Vendor_Name_out', `Vendor_Adress`='$Vendor_Adress_out', `Email_Adress`='$Email_Adress_out', `Tel_No`='$Tel_No_out', `ATTENTION`='$ATTENTION_out', `RFQ_NO`='$RFQ_NO_out', `DEADLINE`='$DEADLINE_out', `rfq_raw_no`='$rfq_raw_no_out', `Prepared_By`='$Prepared_By_out', `Position`='$Position_out'");
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM