1

I can't find my mistake for a few hours already, and I keep getting the same error:

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 ' Users_id = '11'' at line 1 in /home/ubuntu/workspace/pset7/vendor/library50-php-5/CS50/CS50.php on line 352

Here is the line of code it is related to:

CS50::query("SELECT * FROM Portfolios WHERE Symbol = ?, Users_id = ?", $entered_symbol, $_SESSION["id"])

Here is the whole piece:

$entered_symbol = $_POST["symbol"];

 if(.....)
 ......
 // see if you own such stock 
 else if (CS50::query("SELECT * FROM Portfolios WHERE Symbol = ?, Users_id = ?", $entered_symbol, $_SESSION["id"]) < 1)
{
   apologize("You don't own such stock");
}

Almost the same error here:

CS50::query("DELETE FROM Portfolios WHERE Users_id = ?, Symbol = ?", $_SESSION["id"], $entered_symbol);

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 ' Symbol = 'HON'' at line 1 in /home/ubuntu/workspace/pset7/vendor/library50-php-5/CS50/CS50.php on line 352

Thank you very much!

0

From MySQL Doc

The WHERE clause, if given, indicates the condition or conditions that rows must satisfy to be selected. where_condition is an expression that evaluates to true for each row to be selected. The statement selects all rows if there is no WHERE clause.

Example: .....WHERE var1 = val1 AND var2 = val2...

1
  • 1
    oh, what a shame - such a simple mistake. Thank you very much for your help! – Vitale Aug 2 '16 at 12:28

You must log in to answer this question.

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