mysql - Updating a phpmyadmin table through Php using a url varible -


im having problem when trying implement edit page in php.

getting items database doesent pose problem, yet trying update tells me have missed field , trying skip check leaves me unedited table.

to explain more, there page directs 1 while passing on id (propertyid) veriable , use grab desired variables.

can @ code , tell me have done wrong, have prevously got similar page working , getting quite flustered trying figure out why 1 isent.

<?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');      //  details     connect();       $propertyid = $_get['propertyid'];      $sql = "select * properties propertyid='$propertyid' limit 1";     $result = @mysql_query($sql) or die('unable run query');     $record = mysql_fetch_object($result);      mysql_close();            // check see if form has been submitted     if (isset($_post['submit']))     {         // check see 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 sql query add comment               $sql = "update property set propertyid = '$propertyid', img = '$img', address = '$address', price = '$price', landlordname = '$landlordname', description = '$description' propertyid = $propertyid";              // connect database             connect();              // run query , store result in variable             $result = mysql_query($sql) or die("could not run query1");              // close connection database             mysql_close();              // check if query successful             if ($result)             {                 $message = '<div class="success"><p>you have edited article details.</p><p>please <a href="animal_manage.php">click here</a> view animal list.</p></div>';             }             else             {                 $message = '<div class="error"><p>there error editing details, please try again</p></div>';             }         }         else         {             $message = '<div class="error"><p>please make sure fill fields in before submitting 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> return home page</p> <?php     } ?> </form> </div> </div>  </body> </html> <?php } ?> 

my best guess problem revolve around

// check see if form has been submitted     if (isset($_post['submit']))     {         // check see 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 sql query add comment               $sql = "update property set propertyid = '$propertyid', img = '$img', address = '$address', price = '$price', landlordname = '$landlordname', description = '$description' propertyid = $propertyid";              // connect database             connect();              // run query , store result in variable             $result = mysql_query($sql) or die("could not run query1");              // close connection database             mysql_close();              // check if query successful             if ($result)             {                 $message = '<div class="success"><p>you have edited article details.</p><p>please <a href="animal_manage.php">click here</a> view animal list.</p></div>';             }             else             {                 $message = '<div class="error"><p>there error editing details, please try again</p></div>';             }         }         else         {             $message = '<div class="error"><p>please make sure fill fields in before submitting form.</p></div>';         }     } 

and below section, problem im not sure exactly

<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" /> 


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -