Jump to content


Photo

PHP porting to MySQL UPDATE leads to error [solved]


  • Please log in to reply
2 replies to this topic

#1 jeffshen

jeffshen
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 09 August 2006 - 07:29 PM

Dear All,

at the moment I have this

echo $stockname;
echo "<br>";
echo $array[0];
echo "<br>";
echo $numstocks;
echo "<br>";
echo $inprice;
echo "<br>";
echo $currtime;
echo "<br>";
echo $uniqueid;
echo "<br>";
$mysqlinsert = "UPDATE `stocks` SET `code` = $stockname , `name` = $array[0] , `owned` = $numstocks , `buy_price` = $inprice , `timestamp` = $currtime WHERE `key` = $uniqueid";
echo $mysqlinsert;
echo"<br>";
mysql_query($mysqlinsert) or die ("Error inserting records");

where all the random echos are used for debugging... I still cant find the mistake though, when I send that to the browser, the result I get is

0003
HK & CHINA GAS
123
142
1155151474
72
UPDATE `stocks` SET `code` = 0003 , `name` = HK & CHINA GAS , `owned` = 123 , `buy_price` = 142 , `timestamp` = 1155151474 WHERE `key` = 72
Error inserting records

where the last line indicates that the UPDATE function has failed, but I cant see whats wrong with my update function.

can someone please help?

thanks a lot in advance

Jeff

#2 kalivos

kalivos
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts
  • LocationCalifornia

Posted 09 August 2006 - 07:33 PM

Try this

$mysqlinsert = "UPDATE `stocks` SET `code` = '$stockname' , `name` = '".$array[0]."' , `owned` = '$numstocks' , `buy_price` = '$inprice' , `timestamp` = '$currtime' WHERE `key` = '$uniqueid'";
Make a donation to phpfreaks. They need your help![br][br]

#3 jeffshen

jeffshen
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 09 August 2006 - 07:56 PM

Thanks a lot kalivos it worked =)

Jeff




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users