vetman Posted November 30, 2009 Share Posted November 30, 2009 I can't figure out why this update statement isn't working. I've looked at this for hours now, can anyone offer help? <?php include 'config.php'; $getid = $_POST['id']; $getitemno = $_POST['itemno']; $getdescription = $_POST['description']; $getcab = $_POST['cab']; $getearrings = $_POST['earrings']; $getpendant = $_POST['pendant']; $getcut = $_POST['cut']; $getcarat = $_POST['carat']; $getmaterial = $_POST['material']; $getprice = $_POST['price']; $getsold = $_POST['sold']; $getimage_th = $_POST['image_th']; $getimage = $_POST['image']; $getimage2 = $_POST['image2']; $getimage2_th = $_POST['image2_th']; $getavailability = $_POST['availability']; // Connect to server and select database. mysql_connect($dbhost, $dbuser, $dbpass)or die("cannot connect"); mysql_select_db("jtovey")or die("cannot select DB"); echo "Connected to Database <br>"; // update data in mysql database $sql = "UPDATE $dbname SET itemno= '$getitemno', description= '$getdescription', cab= '$getcab', earrings= '$getearrings', pendant= '$getpendant', cut= '$getcut', carat= '$getcarat', material= '$getmaterial', price= '$getprice', sold= '$getsold', image_th= '$getimage_th', image= '$getimage', image2= '$getimage2', image2_th= '$getimage2_th', availability= '$getavailability',WHERE id='$getid'"; $result=mysql_query($sql)or die(mysql_error()); // if successfully updated. if($result){ echo "Successful"; echo "<BR>"; echo "<a href='list_records.php'>View result</a>"; } else { echo "ERROR"; } ?> Thanks in advanced for helping. Quote Link to comment https://forums.phpfreaks.com/topic/183354-cant-figure-out-why-this-update-statement-isnt-working/ Share on other sites More sharing options...
rajivgonsalves Posted November 30, 2009 Share Posted November 30, 2009 you should have got an error on this your update statement is wrong, there is a comma before where this $sql = "UPDATE $dbname SET itemno= '$getitemno', description= '$getdescription', cab= '$getcab', earrings= '$getearrings', pendant= '$getpendant', cut= '$getcut', carat= '$getcarat', material= '$getmaterial', price= '$getprice', sold= '$getsold', image_th= '$getimage_th', image= '$getimage', image2= '$getimage2', image2_th= '$getimage2_th', availability= '$getavailability',WHERE id='$getid'"; should be $sql = "UPDATE $dbname SET itemno= '$getitemno', description= '$getdescription', cab= '$getcab', earrings= '$getearrings', pendant= '$getpendant', cut= '$getcut', carat= '$getcarat', material= '$getmaterial', price= '$getprice', sold= '$getsold', image_th= '$getimage_th', image= '$getimage', image2= '$getimage2', image2_th= '$getimage2_th', availability= '$getavailability' WHERE id='$getid'"; Quote Link to comment https://forums.phpfreaks.com/topic/183354-cant-figure-out-why-this-update-statement-isnt-working/#findComment-967820 Share on other sites More sharing options...
vetman Posted November 30, 2009 Author Share Posted November 30, 2009 Absolutely, I can't believe it, I've looked at this for hours. Works perfectly now. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/183354-cant-figure-out-why-this-update-statement-isnt-working/#findComment-967908 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.