为什么没有更新mysql数据库?

时间:2015-12-17 19:35:44

标签: php database indexing undefined messages

嗨,我有一个更新我的mysql数据库的主要问题......

我有一个表格,在数据库中有多个数组,打印出各种

一些信息 - 我遇到的问题是"编辑"导致错误消息的功能。表格的图片如下图所示。

您可以看到"删除"功能或链接除了"编辑"这似乎工作得很好。错误信息可以在下图中看到。

错误信息显示在下方:

Notice: Undefined index: idz in C:\xampp\htdocs\rajib\editeducation.php on line 23

Notice: Undefined index: full_name in C:\xampp\htdocs\rajib\editeducation.php on line 24

Notice: Undefined index: name_1 in C:\xampp\htdocs\rajib\editeducation.php on line 25

Notice: Undefined index: institution_1 in C:\xampp\htdocs\rajib\editeducation.php on line 26

Notice: Undefined index: instaddress_1 in C:\xampp\htdocs\rajib\editeducation.php on line 27

Notice: Undefined index: monthto_1 in C:\xampp\htdocs\rajib\editeducation.php on line 28

Notice: Undefined index: toyear_1 in C:\xampp\htdocs\rajib\editeducation.php on line 29

Notice: Undefined index: monthto_1_1 in C:\xampp\htdocs\rajib\editeducation.php on line 30

Notice: Undefined index: toyear_1_1 in C:\xampp\htdocs\rajib\editeducation.php on line 31

Notice: Undefined index: graduate_1 in C:\xampp\htdocs\rajib\editeducation.php on line 32

Notice: Undefined index: averages_1 in C:\xampp\htdocs\rajib\editeducation.php on line 33

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens' in C:\xampp\htdocs\rajib\editeducation.php:37 Stack trace: #0 C:\xampp\htdocs\rajib\editeducation.php(37): PDOStatement->execute(Array) #1 {main} thrown in C:\xampp\htdocs\rajib\editeducation.php on line 37

"编辑"的代码链接打印在下面:

    <?php

include('dbcategory.php');

$full_name = $_GET["full_name"];
$idz = $_GET["idz"];

$query1 = "SELECT * FROM education WHERE idz ='$idz' AND full_name = '$full_name'";
$record_set1 = $dbs->prepare($query1);
$record_set1 -> execute();
$row1 = $record_set1->fetch(PDO::FETCH_ASSOC);
//if ($_SERVER["REQUEST_METHOD"] == "POST")
//{
/* $name_1s = "";
$institution_1s = "";
$instaddress_1s = "";
$monthto_1s = "";
$toyear_1s = "";
$monthto_1_1s = "";
$toyear_1_1s = "";
$graduate_1s = "";
$averages_1s = ""; */
$idz = $_POST["idz"];
$full_name = $_POST["full_name"];
$name_1s = $_POST["name_1"];
$institution_1s = $_POST["institution_1"];
$instaddress_1s = $_POST["instaddress_1"];
$monthto_1s = $_POST["monthto_1"];
$toyear_1s = $_POST["toyear_1"];
$monthto_1_1s = $_POST["monthto_1_1"];
$toyear_1_1s = $_POST["toyear_1_1"];
$graduate_1s = $_POST["graduate_1"];
$averages_1s = $_POST["averages_1"];

$query12 = "UPDATE education SET `full_name`=?,`name_1`=?,`institution_1`=?,`instaddress_1`=?,`monthto_1`=?,`toyear_1`,`monthto_1_1`=?, `toyear_1_1`=?, `graduate_1`=?, `averages_1`=? WHERE `idz`=?";
$bb = $dbs->prepare($query12);
$bb ->execute(array($full_name, $name_1s, $institution_1s, $instaddress_1s,$monthto_1s,$toyear_1s,$monthto_1_1s,$toyear_1_1s,$graduate_1s,$averages_1s, $idz));
//}
if (isset($_SERVER["HTTP_REFERER"])) {
        header("Location: " . $_SERVER["HTTP_REFERER"]);
}   

//header("location:editjapplications.php?id=$id");

?>

以下是&#34;教育&#34;的数据库 - 以及当&#34;编辑链接&#34;时更新各个字段时与上述代码对应的所有列的顺序。点击:

我很困惑为什么代码在&#34;删除&#34;按钮似乎工作得很好。谁愿意伸出援手?

更新:代码似乎给出了我似乎无法理解的错误。删除链接有效,它运行在同一个数据库...

更新#2:当我更改字段中的数据时,结果应该有更新...现在有人得到它吗?

更新#3:这是下面编辑功能的更新代码 -

    <?php

include('dbcategory.php');

$full_name = $_GET["full_name"];
$idz = $_GET["idz"];

$query1 = "SELECT * FROM education WHERE idz ='$idz' AND full_name = '$full_name'";
$record_set1 = $dbs->prepare($query1);
$record_set1 -> execute();
$row1 = $record_set1->fetch(PDO::FETCH_ASSOC);
//if ($_SERVER["REQUEST_METHOD"] == "POST")
//{
/* $name_1s = "";
$institution_1s = "";
$instaddress_1s = "";
$monthto_1s = "";
$toyear_1s = "";
$monthto_1_1s = "";
$toyear_1_1s = "";
$graduate_1s = "";
$averages_1s = ""; */
$idz = isset($_POST['idz']) ? $_POST['idz'] : '';;
$full_name = isset($_POST['full_name']) ? $_POST['full_name'] : '';
$name_1s = isset($_POST['name_1']) ? $_POST['name_1'] : '';
$institution_1s = isset($_POST['institution_1']) ? $_POST['institution_1'] : '';
$instaddress_1s = isset($_POST['instaddress_1']) ? $_POST['instaddress_1'] : '';
$monthto_1s = isset($_POST['monthto_1']) ? $_POST['monthto_1'] : '';
$toyear_1s = isset($_POST['toyear_1']) ? $_POST['toyear_1'] : '';
$monthto_1_1s = isset($_POST['monthto_1_1']) ? $_POST['monthto_1_1'] : '';
$toyear_1_1s = isset($_POST['toyear_1_1']) ? $_POST['toyear_1_1'] : '';
$graduate_1s = isset($_POST['graduate_1']) ? $_POST['graduate_1'] : '';
$averages_1s = isset($_POST['averages_1']) ? $_POST['averages_1'] : '';

$query12 = "UPDATE education SET `full_name`=?,`name_1`=?,`institution_1`=?,`instaddress_1`=?,`monthto_1`=?,`toyear_1`,`monthto_1_1`=?, `toyear_1_1`=?, `graduate_1`=?, `averages_1`=? WHERE `idz`=?";
$bb = $dbs->prepare($query12);
$bb ->execute(array($full_name, $name_1s, $institution_1s, $instaddress_1s,$monthto_1s,$toyear_1s,$monthto_1_1s,$toyear_1_1s,$graduate_1s,$averages_1s, $idz));
//}
if (isset($_SERVER["HTTP_REFERER"])) {
        header("Location: " . $_SERVER["HTTP_REFERER"]);
}   

//header("location:editjapplications.php?id=$id");

?>

我现在只收到一个错误 -

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens' in C:\xampp\htdocs\rajib\editeducation.php:37 Stack trace: #0 C:\xampp\htdocs\rajib\editeducation.php(37): PDOStatement->execute(Array) #1 {main} thrown in C:\xampp\htdocs\rajib\editeducation.php on line 37

这些令牌似乎确实匹配......那么问题可能是什么呢?在这个例子中有任何接受者吗?

0 个答案:

没有答案
相关问题