I've read the guidelines for error checking and already had it all in place, but I'm getting no love from my MySQL server over what is a really very simple query. It's kicking my ass and it really shouldn't be.
I'm trying to execute the following code as a page that returns an image called from a database.
Code is as following:
Code: Select all
error_reporting(E_ALL);
$link = mysql_connect('notmyreal.databasehost.com', 'notmyrealusername', 'notmyrealpassword');
if (!$link) {die('Could not connect: ' . mysql_error());}
$query = sprintf("SELECT photo FROM djs WHERE djid=%s", $_GET['id']);
$result = mysql_query($query, $link);
if(!$result) { $message = 'Invalid query: ' . mysql_error($link) . "<br/>\n" . 'Whole query: ' . $query; die($message); }
$row = mysql_fetch_assoc($result);
header("Content-type: image/jpeg");
print $row['photo'];I've been out of the game a while but damn...Invalid query: No database selected
Whole query: SELECT photo FROM djs WHERE djid = 1
Any ideas?
-Adam