I've got PHP script that uses an SQL query to save JSON in a variable. The query is something like this (I've changed the names of the columns to something more general)
$value = $_GET['value'];
SELECT column1 AS 'col1', column2 AS 'col2', column3 AS 'col3', column4 AS 'col4', column5 AS 'col5'
FROM db.dbo.table
WHERE column5 = $value
The variable comes from another page, and it is a string that may or may not contain a space. However, this does not return any JSON and I'm not sure why (It just returns []). This example script works perfectly in SQL Server, but when I try to run it in PHP, it doesn't work. If I get rid of the line WHERE column5 = $value, the script returns JSON. This is the line that passes the variable in a JS script on the other page
return '<a href="/script.php?value=' + data + '" target="_blank">Example</a>'
I'm sure it's something minor, but can someone tell me what is wrong? Thanks
...WHERE column5 = '$value'. Also don't forget escaping the params.