使用url变量通过Php更新phpmyadmin表

使用url变量通过Php更新phpmyadmin表,php,mysql,phpmyadmin,edit,Php,Mysql,Phpmyadmin,Edit,我在尝试用php实现编辑页面时遇到了一个问题 从数据库中获取项目不会带来任何问题,但是尝试更新它会告诉我,我遗漏了一个字段,尝试跳过检查只会留下一个未编辑的表 为了进一步解释,有一个页面在传递id(propertyID)veriable时指向这个页面,我们使用它获取所需的变量 任何人都可以看看代码,告诉我我做错了什么,我以前有一个类似的页面工作,我很慌乱,试图找出为什么这一个是 <?php // Start sessions include('includes/security.inc

我在尝试用php实现编辑页面时遇到了一个问题

从数据库中获取项目不会带来任何问题,但是尝试更新它会告诉我,我遗漏了一个字段,尝试跳过检查只会留下一个未编辑的表

为了进一步解释,有一个页面在传递id(propertyID)veriable时指向这个页面,我们使用它获取所需的变量

任何人都可以看看代码,告诉我我做错了什么,我以前有一个类似的页面工作,我很慌乱,试图找出为什么这一个是

<?php


// Start sessions
include('includes/security.inc.php');
authorise();



if (!isset($_GET['propertyID']) || !is_numeric($_GET['propertyID']))
{
    header('Location:./houselist.php');
}
else
{
// Include connection file
include('includes/connection.inc.php');

    // Get  details
    connect();


    $propertyID = $_GET['propertyID'];

    $sql = "SELECT * FROM Properties WHERE propertyID='$propertyID' LIMIT 1";
    $result = @mysql_query($sql) or die('Unable to run query');
    $record = mysql_fetch_object($result);

    mysql_close();      

    // Check to see if the form has been submitted
    if (isset($_POST['submit']))
    {
        // Check to see all fields have been completed
    $address = $_POST['address'];
    $categoryID = $_POST['categoryID'];
    $price = $_POST['price'];
    $landlordName = $_POST['landlordName'];
    $img = $_POST['img'];
    $description= $_POST['description'];


    if (!empty($address) && !empty($categoryID) && !empty($price) && !empty($landlordName) && !empty($img) && !empty($description))
        {
            // Create an SQL query to add the comment


            $sql = "UPDATE property SET propertyID = '$propertyID', img = '$img', address = '$address', price = '$price', landlordName = '$landlordName', description = '$description' WHERE propertyID = $propertyID";

            // Connect to the database
            connect();

            // Run the query and store the result in a variable
            $result = mysql_query($sql) or die("Could not run query1");

            // Close connection to the database
            mysql_close();

            // Check if query was successful
            if ($result)
            {
                $message = '<div class="success"><p>You have successfully edited Article details.</p><p>Please <a href="Animal_Manage.php">Click Here</a> to view the Animal list.</p></div>';
            }
            else
            {
                $message = '<div class="error"><p>There was an error editing details, please try again</p></div>';
            }
        }
        else
        {
            $message = '<div class="error"><p>Please make sure you fill all fields in before submitting the form.</p></div>';
        }
    }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="css/960.css"/>
    <link rel="stylesheet" type="text/css" href="css/demo.css"/>
    <link rel="stylesheet" type="text/css" href="css/960_24_col.css"/>
    <link rel="stylesheet" type="text/css" href="css/reset.css"/>
    <link rel="stylesheet" type="text/css" href="css/text.css"/>
    <link rel="stylesheet" type="text/css" href="css/style.css"/>
    <title>Complete Property Solutions</title>
<title>Homescreen - Complete Property Solutions</title>
</head>

<body>

<div class="container_24" id="container">
    <div class="grid_24" id="banner">
        <a href="home.php"><img src="img/banner.png" width="960" height="92" /></a>
    </div>
    <div class="grid_18" id="nav" align="right">
        <ul id="topnav">
            <li><a href="home.php">Home</a></li>
            <li><a href="categories.php">Properties</a></li>
            <li><a href="landloeds.php">Landlords</a></li>
            <li><a href="tenants.php">Tenants</a></li>
            <li><a href="logout.php">Logout</a></li>
        </ul>
    </div>
    <div class="grid_6" id="search" align="right">
    <form action="search.php" method="GET"> 
        <input type="text" name="term" size="15">
          <input type="submit" value="Search"> 
    </form>
    </div>

</div>
<div class="container_24" id="container" align="center">
<div id="container">
  <form id="PropertyEdit" name="PropertyEdit" method="post" action="<? echo $_SERVER['PHP_SELF'] . "?propertyID=" . $propertyID; ?>">
  <input type="hidden" name="propertyID" id="propertyID" value="<?php echo $propertyID; ?>" />

<?php
    if (isset($message))
    {
        echo $message;  
    }
    else
    {
?>


 <div class="label"><label for="propertyID"></label></div>
  <div class="input"><input type="hidden" name="propertyID" id="propertyID" tabindex="1" value="<? echo $record->propertyID; ?>" /></div>  
  <br />

     <div class="label"><label for="categoryID">Category</label></div>
  <div class="input"><input type="text" name="categoryID" id="categoryID" tabindex="1" value="<? echo $record->categoryID; ?>" /></div>  
  <br />

    <div class="label">
      <label for="address">Address:</label></div>
  <div class="input"><input type="text" name="address" id="address" tabindex="1" value="<? echo $record->address; ?>" /></div>  
  <br />

 <div class="label"><label for="price">Price:</label></div>
  <div class="input"><input type="text" name="Price" id="price" tabindex="3" value="<? echo $record->price; ?>" /></div>


  <div class="label"><label for="landlordName">Landlord</label></div>
  <div class="input"><input type="text" name="landlordName" id="landlordName" tabindex="1" value="<? echo $record->landlordName; ?>" /></div>  
  <br />
   <div class="label"><label for="img">Image</label></div>
  <div class="input"><input type="text" name="img" id="img" tabindex="1" value="<? echo $record->img; ?>" /></div>  
  <br />
<div class="label"><label for="description">Description:</label></div>
  <div class="input"><textarea name="description" id="description" cols="50" rows="10" tabindex="5"><? echo $record->description; ?></textarea></div>
  <br />
  <div class="label">&nbsp;</div>
  <div class="input">
    <input type="reset" name="reset" id="reset" value="Reset" tabindex="6" />
    <input type="submit" name="submit" id="submit" value="Submit" tabindex="7" />
  </div>
  <p class="normal"><a href="index.php">Click Here</a> to Return to the Home page</p>
<?php
    }
?>
</form> </div>
</div>

</body>
</html>
<?php
}
?>

请。它们不再得到维护,而是在使用。相反,请了解并使用。您能隔离出出现问题的代码吗?
大写价格用于页面文本,而不是代码。至于我使用mysql函数的原因是,这是我目前正在做的一个模块,我需要这样做,但是你的输入名称属性中有
Price
// Check to see if the form has been submitted
    if (isset($_POST['submit']))
    {
        // Check to see all fields have been completed
    $address = $_POST['address'];
    $categoryID = $_POST['categoryID'];
    $price = $_POST['price'];
    $landlordName = $_POST['landlordName'];
    $img = $_POST['img'];
    $description= $_POST['description'];


    if (!empty($address) && !empty($categoryID) && !empty($price) && !empty($landlordName) && !empty($img) && !empty($description))
        {
            // Create an SQL query to add the comment


            $sql = "UPDATE property SET propertyID = '$propertyID', img = '$img', address = '$address', price = '$price', landlordName = '$landlordName', description = '$description' WHERE propertyID = $propertyID";

            // Connect to the database
            connect();

            // Run the query and store the result in a variable
            $result = mysql_query($sql) or die("Could not run query1");

            // Close connection to the database
            mysql_close();

            // Check if query was successful
            if ($result)
            {
                $message = '<div class="success"><p>You have successfully edited Article details.</p><p>Please <a href="Animal_Manage.php">Click Here</a> to view the Animal list.</p></div>';
            }
            else
            {
                $message = '<div class="error"><p>There was an error editing details, please try again</p></div>';
            }
        }
        else
        {
            $message = '<div class="error"><p>Please make sure you fill all fields in before submitting the form.</p></div>';
        }
    }
<div class="container_24" id="container" align="center">
<div id="container">
  <form id="PropertyEdit" name="PropertyEdit" method="post" action="<? echo $_SERVER['PHP_SELF'] . "?propertyID=" . $propertyID; ?>">
  <input type="hidden" name="propertyID" id="propertyID" value="<?php echo $propertyID; ?>" />

<?php
    if (isset($message))
    {
        echo $message; 
    }
    else
    {
?>


 <div class="label"><label for="propertyID"></label></div>
  <div class="input"><input type="hidden" name="propertyID" id="propertyID" tabindex="1" value="<? echo $record->propertyID; ?>" /></div>  
  <br />

     <div class="label"><label for="categoryID">Category</label></div>
  <div class="input"><input type="text" name="categoryID" id="categoryID" tabindex="1" value="<? echo $record->categoryID; ?>" /></div>  
  <br />

    <div class="label">
      <label for="address">Address:</label></div>
  <div class="input"><input type="text" name="address" id="address" tabindex="1" value="<? echo $record->address; ?>" /></div>  
  <br />

 <div class="label"><label for="price">Price:</label></div>
  <div class="input"><input type="text" name="Price" id="price" tabindex="3" value="<? echo $record->price; ?>" /></div>


  <div class="label"><label for="landlordName">Landlord</label></div>
  <div class="input"><input type="text" name="landlordName" id="landlordName" tabindex="1" value="<? echo $record->landlordName; ?>" /></div>  
  <br />
   <div class="label"><label for="img">Image</label></div>
  <div class="input"><input type="text" name="img" id="img" tabindex="1" value="<? echo $record->img; ?>" /></div>  
  <br />
<div class="label"><label for="description">Description:</label></div>
  <div class="input"><textarea name="description" id="description" cols="50" rows="10" tabindex="5"><? echo $record->description; ?></textarea></div>
  <br />
  <div class="label">&nbsp;</div>
  <div class="input">
    <input type="reset" name="reset" id="reset" value="Reset" tabindex="6" />
    <input type="submit" name="submit" id="submit" value="Submit" tabindex="7" />