my while loop is working but as you can see on the last line i do a vard_dump() it shows 2 values in the array, but yet i only get 1 result from my previous page even though there are 2 in the array.
On my previous page i have a list of items, where you can choose multiple ones via a checkbox (on the second page where the $_POST variable is) i captured that input. it shows on the vardump() that it is actually there. are you saying that my SQL query might be at fault here. as in my SQL each item has a unique ID and the value im checking is basicaly to see $_post = any id in the database and display the multiple ID as per previous page in a while loop…
You are checking for which row the column value is literally219,220,1004.
But 219,220,1004 is not a number so MySQL doesn’t understand that and it stops parsing after 2191. If you want all of those numbers you need to modify your query that want the rows where the ID is 219 or the ID is 220 or the ID is 1004.
1 It should have just went instead of you ask me, but ok.
What a weird hack MySQL does here. And another item on my pro-postrges-list
Postgres:
ERROR: invalid input syntax for integer: "2,3,4"
At least MySQL throws an error when the “list” is unescaped
select * from ids where id = 2,3,4
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 '3,4'
It’s basically the same PHP and JavaScript do when casting such a value to an int (or indeed on loose comparison).
However I do agree that throwing an error like Postgres does is a lot nicer
Same here. I realize mistakes in logic can’t be easily detected (eg. == instead of === ) but I would have expected a syntax error or wrong data type to throw an error.
Cool. Next up is learning how to use prepared statements, as this query is open for SQL Injection.
Not that it’s much of a problem for this one, but there will certainly be others where it is a problem.