Hi all,
I am working on the php script as I am using this for reading the images from each rows on mysql database. There are two rows that I have store in mysql already, so there is a little problem as I want you to take a look at this current code:
<?php
session_start();
define('DB_HOST', 'localhost');
define('DB_USER', 'mydbusername');
define('DB_PASSWORD', 'mydbpassword');
define('DB_DATABASE', 'mydbusername');
$username = (int)$_GET['username'];
$errmsg_arr = array();
$errflag = false;
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
function clean($var)
{
return mysql_real_escape_string(strip_tags($var));
}
$qrytable1="SELECT images FROM images_list WHERE username=$username";
$result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error());
while ($row = mysql_fetch_array($result1)) {
$details = getimagesize($row['images']);
header ('Content-Type: ' . image_type_to_mime_type($details[2]));
echo file_get_contents($row['images']);
}
?>
There are two hotlinks images that I have stored in each row. When I entered the id at the end of the url, it will search the id in the database while it will look for the images through with the column name, the id and the username. The first image did printed on my php page when I entered the id, but the random images did not print out when I enter with different id.
Do you know where the trouble is and what I need to make some changes?