Page 1 of 1

Having a problem updating using my Primary Key

Posted: Thu Aug 07, 2008 8:07 am
by nightswore
So I set a primary key to auto-increment so that I can keep my records straight. Now when i try to use it as the "WHERE" clause for my UPDATE line of code, it starts bugging out on me and not updating anything.

Code: Select all

 
mysql_query("UPDATE `intranet`.`getready` SET `deliverytype` = '$deliverytype', `plateexpdate` = '$plateexpdate', `platenumber` = '$platenumber',
`deliverydate` = '$deliverydate', `time` = '$time', `soldto` = '$soldto', `city` = '$city', zip = '$zip', `homephone` = '$homephone',
`workphone` = '$workphone', `year` = '$year', `make` = '$make', `model` = '$model', `color` = '$color',
`location` = '$location', `vin` = '$vin', `miles` = '$miles', `undercoating` = '$undercoating', `rustproofing` = '$rustproofing', `washfordelivery` = '$washfordelivery',
`fabrictreatment` = '$fabrictreatment', `washforshow` = '$washforshow', `auctiondetail` = '$auctiondetail', `fillfuel` = '$fillfuel', `fivegalfuel` = '$fivegalfuel', `bodyestimate` = '$bodyestimate',
useddetail = '$useddetail', aquapel = '$aquapel', simonize = '$simonize', service = '$service', stateinspection = '$stateinspection', emissionscheck = '$emissionscheck',
`safetycheck` = '$safetycheck', `lubeoilfilter` = '$lubeoilfilter', `oemcertify` = '$oemcertify', `universal` = '$universal', `valueserviced` = '$valueserviced', `installparts` = '$installparts',
`roadhazard` = '$roadhazard', `nitrogen` = '$nitrogen', `partnum1` = '$partnum1', `partnum2` = '$partnum2', `partdescript1` = '$partdescript1', `partdescript2` = '$partdescript2',
`partprice1` = '$partprice1', `partprice2` = '$partprice2', `other1` = '$other1', `other2` = '$other2', `other3` = '$other3', `other4` = '$other4',
`notes` = '$notes', `salesperson` = '$salesperson', `salesmanager` = '$salesmanager', `notes2` = '$notes2'
    WHERE CONVERT( `getready`.`getready_id` USING utf8 ) = '$key' ");
 
Anyway the variables here have been passed from a previous page using POST data and have all been made as such:

Code: Select all

$variable = $HTTP_POST_VARS['variable'];
And when you echo the variables before the update, they all come through so that isn't the problem. The main issue is that when I try to use the line I'm altering's primary key value, it apparently is having a hard time recognizing it. Let me know whats up. Thanks.

Note: Yes I've logged in at this point and have access to what I'm updating. Also, the CONVERT part of the last line is me pretty much copying what PHPmyadmin does when it updates its own data trying to get the syntax exactly right so that my data will update properly, its probably not neccessary.

Re: Having a problem updating using my Primary Key

Posted: Thu Aug 07, 2008 8:14 am
by ghurtado
Try to output your SQL statement before you run it:

Code: Select all

$sql = "select ... ";
echo $sql;
if(!mysql_query($sql)){
  echo mysql_error();
} 
Let us know the result