找不到PHP |对象!简单积垢

找不到PHP |对象!简单积垢,php,Php,我仍在试用PHP和数据库功能。我也不熟悉堆栈溢出。 我在更新和删除数据库中的一行时遇到了问题,但现在更新是个问题,如果我能得到帮助,肯定会删除。 我有数据库“dbSample”,它有3列“id、name、address、email”。 我在正确重定向到更新类时遇到问题,每次都会显示错误。 下面是上述连接文件:(sample/class/dbconnection.php): <?php /* ==============================SQL Co

我仍在试用PHP和数据库功能。我也不熟悉堆栈溢出。 我在更新和删除数据库中的一行时遇到了问题,但现在更新是个问题,如果我能得到帮助,肯定会删除。 我有数据库“dbSample”,它有3列“id、name、address、email”。 我在正确重定向到更新类时遇到问题,每次都会显示错误。

下面是上述连接文件:(sample/class/dbconnection.php):

    <?php

    /*
    ==============================SQL Connection=================================
      */

    $connections = mysqli_connect("localhost","root","","dbSample"); //checks database connection
        if(mysqli_connect_errno()){
            echo '<script type="text/javascript">alert("' . "Database Status: " . mysqli_connect_error() . '")</script>';
        }

    ?>
<?php require 'class/dbconnection.php';?>
<html>
<head>
</head>
<body>
<div>
<?php include 'class/dbupdate.php'; ?>
</div>
</body>
</html>
<?php

/*
==============================SQL Update=================================
  */

$view_query = mysqli_query($connections, "SELECT * FROM tblSample");

echo "<table border = '1'>";
echo "<tr>
        <td>Name</td>
        <td>Address</td>
        <td>Email</td>

        <td>Option</td>

        </tr>";

while($row = mysqli_fetch_assoc($view_query)){ //make variables to hold the values from the table

    $user_id = $row["id"];

    $db_name = $row["name"];
    $db_address = $row["address"];
    $db_email = $row["email"];

    //get the value id and pass it
    echo "<tr>
        <td>$db_name</td>
        <td>$db_address</td>
        <td>$db_email</td>

        <td><a href='class/updatepass.php?id=$user_id'>Update</a></td>

        </tr>";

}

echo "</table>";

?>
<?php

require_once(__DIR__."\dbconnection.php");

$user_id = $_REQUEST["id"];

$get_record = mysqli_query($connections, "SELECT * FROM tblSample WHERE id='$user_id'");

while($row_edit = mysqli_fetch_assoc($get_record)){
    $db_name = $row_edit["name"];
    $db_address = $row_edit["address"];
    $db_email = $row_edit["email"];
}

?>

<form method="POST" action="class/updatenow.php">
    <input type="hidden" name="user_id" value="<?php echo $user_id; ?>">
    Name: <input type="text" name="new_name" value="<?php echo $db_name; ?>">

    <hr />

    Address: <input type="text" name="new_address" value="<?php echo $db_address; ?>">

    <hr />

    Email: <input type="text" name="new_email" value="<?php echo $db_email; ?>">

    <hr />

    <input type="submit" value="Update">
</form>
<?php

header('Content-Type: text/plain; charset=utf-8');

require_once(__DIR__."\class\updatepass.php");
require_once(__DIR__."\class\dbconnection.php");

$user_id = $_POST["id"];

$new_name = $_POST["new_name"];
$new_address = $_POST["new_address"];
$new_email = $_POST["new_email"];

mysqli_query($connections, "UPDATE tblSample SET name='$new_name', address='$new_address', email='$new_email' WHERE id='$user_id'");

echo '<script type="text/javascript">alert("' . "Record has been updated" . '")</script>';
header('location: dbsample.php');

?>

在您的上一个
位置:dbsample.php
,不应该是
位置:sample/dbsample.php
?只需将您的完整url。。。。例如,如果找不到您访问的资源或页面,则会发生错误。我想资源/页面的url可能有问题,请检查url@NigelRen这部分显然有效。。