Jump to content

Can't figure out why this "update Statement isn't working.


vetman

Recommended Posts

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.

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'";

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.