You surely know that in PHP code, if you tried to do
you would get an error, right?
Because JCP is not a number, is not a string, and is not a built-in PHP keyword.
So you would fix it by doing
$xyz = "JCP";
$xys = 'JCP';
Guess what: SAME THING in SQL!!!
If you do *NOT* put '...' around a value in SQL queries (in any version of SQL, not just mySQL) then SQL *MUST* treat the value as either a number *OR* a SQL keyword *OR* a field in your database table.
So MySQL is seeing you do
.... AND ticker = JCP
And it says: Well, JCP isn't a number. And I know JCP isn't a SQL keyword. So it *MUST* be the name of a column in his stocks
table. But wait, there isn't any column by that name. Okay, give him an error: Unknown column 'JCP'
The easy fix, of course, is to put '...' around the value:
.... AND ticker = '$ticker' ";
(and yes, PHP will ignore those '...' and assume they are part of the string).
That's step one.
Step 2 is here:
WHERE the_date = $the_date
Guess what? MySQL expects '...' around date values, also. And, on top of that, MySQL only understands dates in the format 'YYYY-MM-DD hh:mm:ss' (with the time part optional). So you need to read the PHP manual to figure out how to format a date like that (not hard).
Nota bene: Actually, MySQL is flexible enough that it *CAN* accept a date as a number, but then the number must be in the format YYYYMMDDhhmmss. And that's probably harder to coax out of PHP than 'YYYY/MM/DD'.