I’m working on a project where I store an id in a table, which is linked with a filename. Upon requesting the id, SQL returns the filename. Yeah, Redis would be best for this sort of thing, but I don’t know how to get that working with PHP.
Anyhow, the following code returns an empty result:
<?php
mysql_connect("localhost","USER","PASSWORD") or die("Unable to connect to SQL server");
mysql_select_db("DATABASE") or die("Unable to select the database");
$scaped = mysql_real_escape_string($_GET["id"]);
$res = mysql_query("SELECT fn from links WHERE id=$scaped");
mysql_close();
echo $res;
?>
I know the key I’m using when requesting the page exists, but I get an empty result and no error. What’s going on?
EDIT: I get:
Unknown column 'rytughguyig78iu786546789' in 'where clause'
Where the long string is my id. My where clause is as is. What’s wrong there?
change your line
to
and by printing out the record: