Php 无法更新数据库中的数据

Php 无法更新数据库中的数据,php,mysql,foreign-keys,inner-join,foreign-key-relationship,Php,Mysql,Foreign Keys,Inner Join,Foreign Key Relationship,我试图更新数据库中的数据,但当我运行代码时,没有出现错误消息,看起来是逻辑错误,但我仍然不知道代码中发生了什么 这是密码 <?php include("conn.php"); SESSION_START(); if($_SESSION["loggedin"]!="true"&& $_SESSION['login'] != '') header("location:login.php"); $aid = $_SESSION[

我试图更新数据库中的数据,但当我运行代码时,没有出现错误消息,看起来是逻辑错误,但我仍然不知道代码中发生了什么

这是密码

 <?php

    include("conn.php");
    SESSION_START();
    if($_SESSION["loggedin"]!="true"&& $_SESSION['login'] != '')
        header("location:login.php");
    $aid = $_SESSION["usr"];
    $result = mysql_query("select r.CustomerID from customer c inner join results r on r.CustomerID = c.CustomerID where c.Username = '".$aid."' ");

    if (false === $result) {
    echo mysql_error();
    }
    $row = mysql_fetch_assoc($result);
?>

<?php
if (isset($_POST["submitbtn"]))
{
    $bookid = $_POST["bookid"];
    $LP = $_POST["LP"];
    $budget = $_POST["budget"];
    $smokep = $_POST["SmokeP"];
    $spreq = $_POST["sp_req"];
        $query = mysql_query("UPDATE `results` SET LP = '$LP', budget = '$budget', SmokeP = '$smokep', sp_req = '$spreq' 
                                WHERE results.BookID = '".$bookid."' and results.CustomerID = '".$result."'");  

        if (false === $query) 
        {
            echo     mysql_error();
        }

        ?>
        <script type = "text/javascript">
                alert("Amendment Saved!!");
        </script>
        <?php

}
?>

首先,您不能在此处启动会话
您必须将它放在打开php标记后的第一行
第二
更新资源=“$new_value”,其中。。。

如果尝试其他解决方案无效,请告诉我

您不能在where条件下使用直接结果变量。您的更新查询正在运行我希望它在您的列中插入一个数组注意:您是否知道有人可以调整
bookid
并删除整个
结果
表?这应该像**where results.bookid=更新中的“$bookid.”和results.CustomerID=”“$row['CustomerID']”.“.”