Jump to content

Archived

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

jeffshen

PHP porting to MySQL UPDATE leads to error [solved]

Recommended Posts

Dear All,

at the moment I have this

[code]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");[/code]

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

Share this post


Link to post
Share on other sites
Try this

$mysqlinsert = "UPDATE `stocks` SET `code` = '$stockname' , `name` = '".$array[0]."' , `owned` = '$numstocks' , `buy_price` = '$inprice' , `timestamp` = '$currtime' WHERE `key` = '$uniqueid'";

Share this post


Link to post
Share on other sites

×

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.