gpt4 book ai didi

php - 更新 php mysql 查询

转载 作者:行者123 更新时间:2023-11-30 00:01:41 24 4
gpt4 key购买 nike

我尝试更新我的查询,看起来没有问题,也没有错误,但我不知道为什么侧边栏上的主题没有更新,请帮助我(我确信没有问题在其他代码页中)

<?php include("includes/connections.php"); ?>
<?php require_once("includes/function.php"); ?>
<?php
if(isset($_POST['submit'])){
$errors = array();
$required_fields = array('menu_name', 'position', 'visible');
foreach($required_fields as $fieldname){
if (!isset($_POST[$fieldname]) || empty($_POST[$fieldname]) && $_POST[$fieldname] != 0){
$errors[] = $fieldname;
}
}
$field_width_lengths = array('menu_name' => 30);
foreach ($field_width_lengths as $fieldname => $maxlength) {
if (strlen(trim(mysqli_real_escape_string($connection , $_POST[$fieldname]))) > $maxlength){
$errors[] = $fieldname;
}
}
if (empty($errors)){
$id = mysqli_real_escape_string($connection, $_GET['subj']);
$menu_name = mysqli_real_escape_string($connection, $_POST['menu_name']);
$position = mysqli_real_escape_string($connection, $_POST['position']);
$visible = mysqli_real_escape_string($connection, $_POST['visible']);
$query = "UPDATE subjects SET
menu_name = '{$menu_name}'
position = {$position}
visible = {$visible}
WHERE id = {$id}";
$result = mysqli_query($connection, $query);

} else {
echo "error dade";
}
}

else{ //if error occurs
}
?>
</nav>
<?php find_selected_page(); ?>
<?php include("includes/header.php"); ?>
<?php navigation($sel_subj, $sel_pages); ?>
<section>
...
</section>
<?php require("includes/footer.php"); ?>

我很乐意帮助我,我搜索了这个问题,但找不到任何有关我的问题的信息。

最佳答案

试试这个

 $query = "UPDATE subjects SET
menu_name = '{$menu_name}',
position = {$position},
visible = {$visible}
WHERE id = {$id}";

为每个列名称添加 ,

关于php - 更新 php mysql 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24978740/

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