Jump to content

mark103

Members
  • Posts

    268
  • Joined

  • Last visited

Everything posted by mark103

  1. oh sorry, i have forgot to define the $username. however, when i input the url address with random id at the end something like this: http://www.mysite.com/myscript.php?id=0 http://www.mysite.com/myscript.php?id=1 ...etc i have got the same output images, do you know why and how to fix this?
  2. that is okay. i have added semi colon on the image = $row, however i am getting another error: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 here's the current code: <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'mydbusername'); define('DB_PASSWORD', 'mypassword'); define('DB_DATABASE', 'mydbname'); $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 image_list WHERE username=$username"; $result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error()); while ($row = mysql_fetch_array($result1)) { $image = $row['images']; $details = getimagesize($image); header ('Content-Type: ' . image_type_to_mime_type($details[2])); readfile($image); } ?> what's wrong?
  3. thanks, but there is a problem. i have got an error: Parse error: syntax error, unexpected T_VARIABLE in /home/myusername/public_html/images.php on line 32 here is the line 32: $details = getimagesize($image); any idea how to correct the error?
  4. im just hotlinking them.
  5. thanks, i have a bit of trouble with the code. I cannot be able to get the output images as it will output the url link on my php page. <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'mydbusername'); define('DB_PASSWORD', 'password'); define('DB_DATABASE', 'mydbname'); $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 user_channel_list WHERE username=$username"; $result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error()); if(isset($username)){ $sql = "SELECT id, images FROM images_list WHERE username = '$username'"; $result = mysql_query($sql) or die("Invalid query: " . mysqli_error()); header("Content-type: image/jpeg"); $im = imagecreatefromstring(mysql_result($result, 0)); imagejpeg($im); imagedestroy($im); } ?> any idea how to fix this?
  6. I have already stored the query strings into mysql which I did get the results returned, so I don't know what to do and how to correct the situation as I am getting. This is what I am trying to do: enter the id at the end of the url something like this: http:www.mysite.com/images.php?id=123 each id i enter at the end of the url, it will enter to mysql database find the id in mysql and find the header called images print out each random image each time i enter the different id on the end of the url do you know how to do this using with this 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']); } ?>
  7. yes it supposed to be so please can you help?
  8. here's the output that it have printed on my php page: SELECT id, images FROM images_list WHERE username=0 Any idea?
  9. yes, the query does not changes when I enter with another string numbers like "2". Do you know how to fix this?
  10. well I have a mysql database where I am casing the username into an integer, so it will find the images whatever i stored in mysql. However, I do realised that I wouldn't need to as long the id and the images coumn name need to be necessary. Sorry, I meant that the image did not changes when I enter with different id at the end of the url. Any idea what I need to do to make some changes in order to get the images displaying with the correct id?
  11. 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?
  12. Hi guys, I need your help. I am using two scripts as one are using for to hotlink the images that I have stored in mysql and the other script i am using for to get access to images.php. The two scripts I am using is link.php and images.php. I have got a problem with the images as I am trying to extact them when I enter the url something like www.mysite.com/link.php?user=test. I can't be able to extact the images when I get access to images.php and input the images in my php page. The image data have displayed as empty array. here's the screenshot: Link.php <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'root'); define('DB_PASSWORD', ''); define('DB_DATABASE', 'hf'); $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)); } $username = clean($_GET['user']); $pass = clean($_GET['pass']); if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />', $errmsg_arr); } else { $insert = array(); if(isset($_GET['user'])) { $insert[] = 'username = \'' . clean($_GET['user']) .'\''; } if(isset($_GET['pass'])) { $insert[] = 'pass = \'' . clean($_GET['pass']) . '\''; } if (count($insert)>0) { $names = implode(',',$insert); if($username) { $sql = 'SELECT `id` FROM `images_list` WHERE `username` = "'.$username.'"'; $result1 = mysql_query($sql) or die('Error:<br />'. $sql .'<br />' . mysql_error()); $res = mysql_fetch_assoc($result1); foreach($res as $row) { echo '<p id="images"><img src="images.php?id='. $row['id'] .'" /></p>'; } } } } Images.php <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'mydbusername'); define('DB_PASSWORD', 'mydbpassword'); define('DB_DATABASE', 'mydbname'); $id = (int)$_GET['id']; $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)); } $sql = 'SELECT `images` FROM `Images_list` WHERE `id` = "'. $id .'"'; $result1 = mysql_query($sql) or die('Error:<br />'. $sql .'<br />' . mysql_error()); $res = mysql_fetch_assoc($result1); foreach($res as $row) { var_dump($row['images']); exit; $details = getimagesize($row['images']); header ('Content-Type: ' . image_type_to_mime_type($details[2])); echo file_get_contents($row['images']); } ?> any idea how to fix this?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.