Mysqli 更新不更新,即使声明成功


mysqli update not updating eventhough stating successful?

我正在构建一个项目,由于某种原因,我无法让我的 Update 语句实际更新。

我在表单中有一些输入字段,这些字段提供了以下变量的详细信息。

这是我的代码:

//update database
$stmt = $mysqli->prepare("UPDATE pages SET 
                    pg_name= ?, 
            pg_title = ?, 
            pg_keywords = ?,
            pg_description = ?,
            pg_header1 = ?,
            pg_header2 = ?,
            pg_maintext = ?,
            pg_active = ? WHERE id = ?");
        $stmt->bind_param('sssssssii', 
            $pg_name,
            $pg_title,
            $pg_keywords,
            $pg_description,
            $pg_header1,
            $pg_header2,
            $pg_maintext,
            $pg_active,
            $id);
        if($stmt->execute() === TRUE){
        $stmt->close();
            echo "Database successfully updated";
        } else {
            echo "There was a problem updating the database.";
        }

我已经测试并且正在从我的表单中设置变量,当我运行脚本时,我收到"成功"消息,但检查我的数据库,什么也没发生。

我错过了什么?:)

感谢您的帮助/

好的

<form action="" method="post">
    <table>
        <tr>
            <td colspan="2"><?php echo "<span style='color: red; font-weight:     bold;'>".$errmsg."</span><br />"; ?></td>
        </tr>
        <tr>
            <td>Page Name:</td>
            <td><input type="text" name="pg_name" id="pg_name" value="<?php     if(isset($id)){ echo $page['pg_title']; }?>" /></td>
        </tr>
        <tr>
            <td>Page Title:</td>
            <td><input type="text" name="pg_title" id="pg_title" value="<?php     if(isset($id)){ echo $page['pg_title']; }?>" /></td>
        </tr>
        <tr>
            <td>Keywords:</td>
            <td><input type="text" name="pg_keywords" id="pg_keywords" value="    <?php if(isset($id)){ echo $page['pg_keywords']; }?>" /></td>
        </tr>
        <tr>
            <td>Description:</td>
            <td><input type="text" name="pg_description" id="pg_description"      value="<?php if(isset($id)){ echo $page['pg_description']; }?>"/></td>
        </tr>
        <tr>
            <td>Main page header:</td>
            <td><input type="text" name="pg_header1" id="pg_header1"  value="<?    php if(isset($id)){ echo $page['pg_header1']; }?>"/></td>
        </tr>
        <tr>
            <td>Subheader:</td>
            <td><input type="text" name="pg_header2" id="pg_header2" value="<?    php if(isset($id)){ echo $page['pg_header2']; }?>" /></td>
        </tr>
        <tr>
            <td>Page text</td>
            <td><textarea name="pg_maintext" id="pg_maintext"><?php     if(isset($id)){ echo $page['pg_maintext']; }?></textarea></td>
        </tr>
        <tr>
            <td>Active?</td>
            <td><select name="pg_active">
                <option value="1">Yes</option>
                <option value="0">No</option>
                </select></td>
        </tr>
        <tr>
            <td><input type="submit" name="submit" id="submit" value="<?php     if(isset($_GET['page_id'])){ echo "Update"; } else { echo "Add"; } ?>" /><?php     if(isset($_GET['page_id'])){ echo "<a href='pages.php' /><input type='button' name='new'     id='new' value='New' /></a>"; } ?></td>
            <td></td>
        </tr>
    </table>
</form>

我已经直接在我的数据库中尝试了SQL推荐,它可以工作。只是无法通过此表单工作。数据库已连接,表单能够从数据库中提取数据。

更新:我已经尝试了我想到的一切 - 这里没有任何效果。我为每个步骤添加了错误报告,因为它认为没有错,所以没有错误标记!我有对SQL的更新访问权限,因为我一直在使用它。

这可能是由于两个问题之一造成的。

-您的$id与数据库表中的条目不匹配,或者:

- 您的 mysql 用户没有更新权限。

鉴于您所说的查询在后端工作,第二个选项似乎最有可能。