0

This -

$updateRow= CS50::query("UPDATE portfolios SET shares =[$newAmount] WHERE user_id = ?  AND symbol = ?", $myid , $_POST['buysym']); - 

results in this -

Fatal error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[14] WHERE user_id = '11' AND symbol = 'QUAD'' at line 1 in /home/ubuntu/workspace/pset7/vendor/library50-php-5/CS50/CS50.php on line 352

$newAmount=14 user_id=11

Any ideas as to what I am doing wrong? Thanks.

1

Maybe you should paste your entire code.

But a longshot: does it work if you put a ? as a placeholder for [$newAmount] and move $newAmount out of the query string to sit beside $myid and $_POST['buysym'] as an argument (right before $myid)?

0

You can follow either of the two approaches:

  1. $updateRow= CS50::query("UPDATE portfolios SET shares ={$newAmount} WHERE user_id = ? AND symbol = ?", $myid , $_POST['buysym']);

  2. $updateRow= CS50::query("UPDATE portfolios SET shares = ? WHERE user_id = ? AND symbol = ?", $newAmount, $myid , $_POST['buysym']);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .