Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Can';不要编辑我的MySQL数据库_Php - Fatal编程技术网

Php Can';不要编辑我的MySQL数据库

Php Can';不要编辑我的MySQL数据库,php,Php,我希望允许我的用户编辑数据库中的行。我正在跟随一个教程,但我似乎无法让它工作。我不知所措,因为我不知道为什么我的变量没有被声明,而我清楚地知道(在我的头脑中) SQL中的1)是错误的,在BusinessID='$BusinessID'之后不能是,(这是最后一个赋值) 2) SQL中的$id未定义。BusinessID='$BusinessID',您的脚本甚至有可能查看使用时发生的情况。而且我不会打字;我会成为stackoh和名字的笑柄名称其他的也一样;更多的打字错误。因此,返回并使用工具检查错误

我希望允许我的用户编辑数据库中的行。我正在跟随一个教程,但我似乎无法让它工作。我不知所措,因为我不知道为什么我的变量没有被声明,而我清楚地知道(在我的头脑中)


SQL中的
1)是错误的,在
BusinessID='$BusinessID'
之后不能是
(这是最后一个赋值)


2) SQL中的
$id
未定义。

BusinessID='$BusinessID',
您的脚本甚至有可能查看使用时发生的情况。而且我不会打字;我会成为stackoh和名字的笑柄<代码>名称
其他的也一样;更多的打字错误。因此,返回并使用工具检查错误,因为您有很多。
=顺便说一句,php是否表示“不相等”。感谢您的回复,您在哪一行看到BusinessID=“$BusinessID”打字错误?除非你的意思是我不能在里面放“$”?很抱歉,我对php非常陌生,所以感觉有点像atm。你错过了很多东西,我的意思是很多。谢谢你的回复,我已经纠正了愚蠢的打字错误。我仍然在工作人员ID上出错,我已经更新了代码以显示更改。但基本上它不喜欢“$StaffID=$_GET['StaffID'”;你只是接受了弗雷德的评论,并把它作为你的答案实际上@MasivuyeCokile他几乎没有触及冰山一角。
     <?php
    // including the database connection file
    include_once("connect.php");

    if(isset($_POST['update']))
    {    
        $StaffID = $_POST["StaffID"];

        $Name=$_POST["Name"];
        $Address=$_POST['Address'];
        $Telephone=$_POST['Telephone'];  
        $BusinessID=$_POST['BusinessID'];

         $result = mysqli_query($conn, "UPDATE staff SET Name='{$Name}',Address='{$Address}',Telephone='{$Telephone}', BusinessID='{$BusinessID}' WHERE StaffID = $StaffID");

        //redirectig to the display page. In our case, it is index.php
        header("Location: HomePHP.php");
    }
}
?>
<?php
//getting id from url
$StaffID = $_GET['StaffID']; //this is what is giving me the error even though it is exactly how it appears in my database

//selecting data associated with this particular id
$result = mysqli_query($conn, "SELECT * FROM staff WHERE StaffID=$StaffID");

while($res = mysqli_fetch_array($result))
{


    $Name = $res['Name'];
    $Address = $res['Address'];
    $Telephone = $res['Telephone'];
    $BusinessID = $res['BusinessID'];
}
?>

    <html>
    <head>    
        <title>Edit Data</title>
    </head>

    <body>
        <a href="select.php">Home</a>
        <br/><br/>

        <form name="form1" method="post" action="select.php">
            <table border="0">
                <tr> 
                    <td>Name</td>
                    <td><input type="text" name="name" value="<?php echo $Name;?>"></td>
                </tr>
                <tr> 
                    <td>Age</td>
                    <td><input type="text" name="age" value="<?php echo $Address;?>"></td>
                </tr>
                <tr> 
                    <td>Email</td>
                    <td><input type="text" name="email" value="<?php echo $Telephone;?>"></td>
                </tr>
                  <tr> 
                    <td>BusinessID</td>
                    <td><input type="text" name="email" value="<?php echo $BusinessID;?>"></td>
                </tr>
                <tr>
                    <td><input type="hidden" name="id" value=<?php echo $_GET['StaffID'];?>></td>
                    <td><input type="submit" name="update" value="Update"></td>
                </tr>
            </table>
        </form>
    </body>
    </html>