Jump to content

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


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

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.