problem with UPDATE function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

problem with UPDATE function

Post by amir »

I am attempting to UPDATE a record and get the following error...

Error adding information for this property: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(proLot='Lot 2',proStreet='Hales Street',proStreetNo='89',proPropType'',proImpro' at line 1


can anyone see what is wrong with the code?

Please use the PHP and CODE tags when posting.

Code: Select all

<?

if(isset($_POST['editProperty']))
{
   // Connect to the database server
     $dbcnx = mysql_connect('localhost', 'poi8643_admin', 'edf742zba');
     if (!$dbcnx) {
          die("<p><b>Unable to connect to the database server at this time.</b></p>");
     }

     // Select the Point Boston database
     if (!mysql_select_db('poi8643_pointboston')) {
          die("<p>Unable to locate the Point Boston database at this time.</p>");
     }

     // insert it into the database
      $up_property_id = $_POST['up_property_id'];
      $ud_proLot = $_POST['ud_proLot'];
     $ud_proStreet = $_POST['ud_proStreet'];
      $ud_proStreetNo = $_POST['ud_proStreetNo'];
      $ud_proPropType = $_POST['ud_proPropType'];
      $ud_proImprovements = $_POST['ud_proImprovements'];
      $ud_proDimensions = $_POST['ud_proDimensions'];
      $ud_proArea = $_POST['ud_proArea'];
      $ud_proAspect = $_POST['ud_proAspect'];
      $ud_proDuplex = $_POST['ud_proDuplex'];
      $ud_proDate = $_POST['ud_proDate'];
      $ud_proPrice = $_POST['ud_proPrice'];
      $ud_proConditions = $_POST['ud_proConditions'];
      $ud_proStatus = $_POST['ud_proStatus'];
     
      $sql = "UPDATE tblProperty SET proLot='$ud_proLot', proStreet='$ud_proStreet', proStreetNo='$ud_proStreetNo', proPropType'$ud_proPropType', proImprovements='$ud_proImprovements', proDimensions='$ud_proDimensions', proArea='$ud_proArea', proAspect='$ud_proAspect', proDuplex='$ud_proDuplex', proDate='$ud_proDate', proPrice='proPrice', proConditions='$ud_proConditions', proStatus='$ud_proStatus' WHERE property_id='$ud_property_id'";

     
//      $sql = "INSERT INTO tblPropsSales (proLot, proStreet, proStreetNo, proPropType, proImprovements, proDimensions, proArea, proAspect, proDuplex, proConditions, proStatus)
//             VALUES
//            ('$proLot', '$proStreet', '$proStreetNo', '$proPropType', '$proImprovements', '$proDimensions', '$proArea', '$proAspect', '$proDuplex', '$proConditions', '$proStatus')";
?>
<table align="center" cellspacing="0px" style="width:760">
   <tr>
     <td height="10" align="left"><?      
     if (mysql_query($sql)) {
          echo "<p>Your information for $proLot has been added.</p>";  
     }
     else {
          echo "<p>Error adding information for this property: ".mysql_error()."</p>";
     }
?>
     </td>
   </tr>
</table>
feyd | fixed broken page layout. :roll:
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: problem with UPDATE function

Post by Christopher »

amir wrote:Error adding information for this property: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(proLot='Lot 2',proStreet='Hales Street',proStreetNo='89',proPropType'',proImpro' at line 1
The error message leads right up to the error. It looks like you are missing an "=" after proPropType.
(#10850)
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

Post by amir »

Thanks a lot,
it works,
Post Reply