php and mysql update

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • whitep8
    New Member
    • Oct 2009
    • 65

    php and mysql update

    Hi All,

    Can anybody see anything wrong with the following...... its a mysql update query, however when ran (and adding vardump) i get nothing added to the database....

    the error is.........


    ERROR: 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 '' at line 1 UPDATE tbl_sellers SET propertytype = 'House
    ', propertyaddress = 'jhgjhgjhg

    ', propadd2 = 'jhgjhgjgh

    ', proptown = 'jgjghjgh

    ', propstatecounty = 'jhgjhgjgh

    ', proppostzip = 'jghjhgjhg

    ', propcountry = '

    ', propbedrooms = 'jhgjhgjhg

    ', propgarage = 'Yes

    ', eighteenplus = '

    ' WHERE ID = 20

    the code is

    Code:
    <?php
    session_start();
    echo $prop_id = $_SESSION['ID'] . "<br>";
    echo $propertytype = $_POST['propertytype'] . "<br>";
    echo $propertyaddress = $_POST['propertyaddress'] . "<br>";
    echo $propadd2 = $_POST['propadd2'] . "<br>";
    echo $proptown = $_POST['proptown'] . "<br>";
    echo $propstatecounty = $_POST['propstatecounty'] . "<br>";
    echo $proppostzip = $_POST['proppostzip'] . "<br>";
    echo $propcountry = $_POST['propcounry'] . "<br>";
    echo $propbedrooms = $_POST['propbedrooms'] . "<br>";
    echo $propgarage = $_POST['propgarage'] . "<br>";
    echo $eighteenplus = $_POST['eighteenplus'] . "<br>";
    ?> 
    <?php
    $host="localhost"; // Host name
    $username="user"; // Mysql username
    $password="pword"; // Mysql password
    $db_name="dbname"; // Database name
    
    // Connect to server and select databse.
    mysql_connect("$host", "$username", "$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");
    
    
    				$sql = "UPDATE tbl_sellers propertytype = '$propertytype', 
    				propertyaddress = '$propertyaddress', 
    				propadd2 = '$propadd2', 
    				proptown = '$proptown', 
    				propstatecounty = '$propstatecounty', 
    				proppostzip = '$proppostzip', 
    				propcountry = '$propcountry', 
    				propbedrooms = '$propbedrooms', 
    				propgarage = '$propgarage', 
    				eighteenplus = '$eighteenplus'
    				WHERE ID = $prop_id";
    $result = mysql_query($sql);
    var_dump($result);
    echo "thanks";
    ?>
  • gbandtb
    New Member
    • Feb 2010
    • 1

    #2
    Hi,

    You are missing "SET" in your MySQL query -- it should be:
    $sql = "UPDATE tbl_sellers SET propertytype = ...

    Comment

    Working...