gpt4 book ai didi

php - Javascript正在发布变量,但我的所有数据都没有输入到数据库中

转载 作者:行者123 更新时间:2023-11-29 13:41:22 26 4
gpt4 key购买 nike

我有一个 MySQL 数据库,我正在使用 AJAX 通过表单向其中添加记录。控制台告诉我,我的所有数据都已发布到 php 页面,并且我没有收到任何错误。但是,并非所有数据都显示在数据库中。

PHP:

    //set values sent from javascript
$evaluator = $_SESSION['id'];
$feedback = $_POST['feedback'];
$student_work = $_POST['student_work'];
$student = $_POST['student'];
$assessment = $_POST['assessment'];
$classwork = $_POST['classwork'];
$best = $_POST['best'];
$subject = $_POST['subject'];
$binder = $_POST['binder'];
$teacherid = $_POST['teacher'];
$formid = $_POST['form'];
$draft_flag = $_POST['s'];
//set draft time to use for saving/updating drafts
$draft_time = date("Y-m-d H:i:s");
//flag that decided what we're saving, ie draft, submit, update.
$flag = $_POST['draft'];
//Querys the database to get the form name
$fquery = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT form_name FROM forms WHERE id_form='$formid' LIMIT 1");
$row = mysqli_fetch_assoc($fquery);
$form_name = $row['form_name'];
//query's the database to get the teacher's school for this evaluation
$tquery = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT id_school FROM teachers WHERE teacher_id='$teacherid' LIMIT 1");
$trow = mysqli_fetch_assoc($tquery);
$id_school = $trow['id_school'];

include_once 'functions/functions.php';

if ($draft_flag == "submit"){

//inserts collected data and sets status as submitted in the evaluations table
$query = "INSERT INTO evaluations SET
id_user = '$evaluator',
time_submitted = LOCALTIME(),
date_submitted = NOW(),
feedback = '$feedback',
student_work_org = '$student_work',
best_works_port = '$best',
binder = '$binder',
assesment_folders = '$assessment',
classwork_organization = '$classwork',
student_desks = '$student',
subject_specific_rubric = '$subject',
id_teacher = '$teacherid',
id_school = '$id_school',
id_form = '$formid',
status = 'Submitted'";

mysqli_query($GLOBALS["___mysqli_ston"], $query);
?>

在所有变量中,这些都不会发布:

$feedback = $_POST['feedback'];
$student_work = $_POST['student_work'];
$student = $_POST['student'];
$assessment = $_POST['assessment'];
$classwork = $_POST['classwork'];
$best = $_POST['best'];
$subject = $_POST['subject'];
$binder = $_POST['binder'];

这 12 个中的 8 个没有发布。

编辑:这是 js 发送的内容:

ajax.send(
"classwork=" + classwork
+ "&student_work=" + student_work
+ "&feedback=" + feedback
+ "&assessment=" + assessment
+ "&best=" + best
+ "&student=" + student
+ "&subject=" + subject
+ "&binder=" + binder
+ "&teacher=" + teacher
+ "&form=" + form
+ "&draft=" + draft
+ "&s=" + s
);

我还有其他几个类似的表单,运行良好。预先感谢您的帮助!

编辑:

请不要告诉我我的语法不正确,除非你要告诉我我错过了逗号或其他东西。 (我检查过,所以我怀疑这就是问题:))我知道这可能不是您插入的方式,但根据http://dev.mysql.com/doc/refman/5.7/en/insert.html它是正确的

刚刚尝试了一下,结果是一样的。

$query = "INSERT INTO evaluations (
id_user,
time_submitted,
date_submitted,
feedback,
student_work_org,
best_works_port,
binder, '$binder',
assesment_folders,
classwork_organization,
student_desks,
subject_specific_rubric,
id_teacher,
id_school,
id_form,
status)
VALUES (
'$evaluator',
LOCALTIME(),
NOW(),
'$feedback',
'$student_work',
'$best',
'$assessment',
'$subject',
'$classwork',
'$student',
'$teacherid',
'$id_school',
'$formid',
'Submitted'
) ";

最佳答案

您的INSERT syntax是错的。这是正确的形式:

INSERT INTO <table name> (
<field name foo>
<field name bar>
.
.
.
)
VALUES (
<value for foo>,
<value for bar>,
.
.
.
)

关于php - Javascript正在发布变量,但我的所有数据都没有输入到数据库中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18036739/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com