I am trying to run a simple SELECT query inside of a PHP class, using the GET variable.
$this->Token = $_GET['Token'] ?? null;
function getRows(){
$query = $this->db->query("SELECT * FROM store_product_images WHERE token = ".$this->Token." ORDER BY display_order ASC");
When I run this, nothing shows, if I remove the WHERE it works fine
tokenis a string, you would need quotes round the value,but using prepared statements solves this and a few other problems.[...] WHERE token = '{$this->Token}' ORDER BY [...]. Anyway, you should really consider to escape your value, or better to use prepared statement, as another has mentioned, your code is vulnerable to SQL injection.