Troubleshooting 101
When troubleshooting code problems, the secret is baby-steps. When you have an error, it is always a single statement (or line) that is producing the error. Create a new file, and put in only enough code to produce your problem, then work until you solve it--one line at a time. Baby-steps.
In keeping with the baby-steps philosophy, let's attack only one problem at a time. Let's look at your SQL problem. Create a new file with only this code:
[PHP]
$conn = mysql_connect("localhost", "user", "pass") OR DIE (mysql_error());
@mysql_select_db ("user_images", $conn) OR DIE (mysql_error());
$sql = "SELECT * FROM images WHERE image_id=".$_GET["iid"];
echo $sql;
if (!$result = mysql_query ($sql, $conn)) {
echo mysql_error();
} else {
echo "
query successful";
}
[/PHP]
Now, call this script directly within your browser using a URL such as http://myserver.com/myscript.php?iid=1
The script should display in your browser the SQL statement that it runs against the database. Examine that statement--do you see anything wrong with it? If not, then copy the statement from your browser window and run it directly against your database. What I mean by that is if you are working with a database, you must have some tool you use to create your tables--right? For many people with MySql, that tool is phpMyAdmin. Do you have access to use phpMyAdmin? If not, whatever tool you use to manage you database, should have a way to paste in a query and execute it. This way you can test that the SQL statement you are generating in your PHP code is actually a valid statement that your database can execute. Maybe it is a valid statement, but it does not return any rows because no rows match the query.
Once you work through this part, you can add more steps---one at a time--baby steps--until you have the whole script working.