mark103
Members-
Posts
268 -
Joined
-
Last visited
Everything posted by mark103
-
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?
-
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?
-
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?
-
im just hotlinking them.
-
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?
-
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']); } ?>
-
yes it supposed to be so please can you help?
-
here's the output that it have printed on my php page: SELECT id, images FROM images_list WHERE username=0 Any idea?
-
yes, the query does not changes when I enter with another string numbers like "2". Do you know how to fix this?
-
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?
-
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?
-
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?
-
do anyone know how to do this?
-
Ok, I have found this that it does hide the path to the image, but I don't know how to add the html tags to the images? $details = getimagesize($row['image_path']); header ('Content-Type: ' . image_type_to_mime_type($details[2])); echo file_get_contents($row['image_path']); And another problem for me, I can't extact the text description from the database. Do you know how to do this to work together with the images?
-
thanks for your help wildteen88, i need two things to get this done. On my php page, the are images that are displaying on my page, but when you open the source, the real image link of the site that i stored the link in the database which it display something like this: <p id="images"><img src="http://www.theimagessite/wp-content/uploads/2008/images.jpg" /></p> I don't want the real images link to be display when you open the source, I want to hide it and i don't want to upload the images on my site, so I want the source to hide the link and display the source something like this: <p id="images"><img src="/images.jpg" /></p> do you know how i could this? And do you know how I can disabled the source to avoid people stealing the source or read it? thanks in advance.
-
hi guys, i am using the php script to extact the images that I have store the url in the database. Now I would like to set the html tags name for the images, I have looked through on google and I have found some results, so I have set the html tags name for the images, but I can't set the tags name because the images will not be printed out. It would only works if I use without the tags. here's the current code: <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'mydbusername'); define('DB_PASSWORD', 'mydbpassword'); 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)); } $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) { $qrytable1="SELECT username, images, text_description FROM images_list WHERE username='$username'"; $result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error()); while ($row = mysql_fetch_array($result1)) { $image_path = getimagesize($row['images']); header ('Content-Type: ' . image_type_to_mime_type($image_path[2])); echo file_get_contents($row['images']), "<p id='text_description'>", $row['text_description'] . "</p>"; } } } } ?> I have tried to modified this, but it doesn't work: $image_path = getimagesize($row['images']); header ('Content-Type: ' . image_type_to_mime_type($image_path[2])); echo "<p id='images'>", $image_path = getimagesize($row['images']) . "</p>";; Any help would be much appreicated.
-
how to display images when stored link in mysql database
mark103 replied to mark103's topic in PHP Coding Help
there is no error, i have got the image on the top and the text description which are on below. I just want to know how to set them next to the images? -
how to display images when stored link in mysql database
mark103 replied to mark103's topic in PHP Coding Help
Thanks for your quick replied jkewlo and thanks for your help, do you know how I can set the description text next to the images without set them under the images? something got to do with this line: echo "<img src ='".$image_path."'>", "<p id='text_description'>", $row['text_description'] . "</p>" ; here's the current code: <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'mydbusername'); define('DB_PASSWORD', 'mydbpassword'); 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)); } $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) { $qrytable1="SELECT username, images, text_description FROM user_list WHERE username='$username'"; $result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error()); while ($row = mysql_fetch_array($result1)) { $image_path = $row['images']; echo "<img src ='".$image_path."'>", "<p id='text_description'>", $row['text_description'] . "</p>" ; } } } } ?> Any help would be much appreciated! -
hi guys, i need your help. i has been searching through on google as i am looking for a php code where i can just stored the images link in the mysql database table, and then display the images. Most of the search results on google they are for stored the images in mysql which is a pretty bad idea. I just want to store the images link in mysql and display the images in php. I can't find it, please can you help? Cheers.
-
i have got a weird problem right here. I have printed out the images from mysql database, so i have added the the text data code in my php script where I can extact the data from mysql, but when I ran my site for a scale test, I saw my site link have been printed out and displaying as a image on my php page which it looks like this: http://mysite.myhostname.com/images.php?user=test&pass=test I find it werid, so if I remove this: echo "<p id='textdata'>"; echo $row['textdata'] . "</p>"; It will extact the images from the database, but I will not be able to extact the data. I can't find the solution to extact the images and the data from mysql database at the same time, it has to be either one of them to get it to works. And I have found out that it will causes huge traffic of the server to make them getting slowing down, so I should have stored the images in the file manager of my webhost but I have no idea how to link them in mysql database. here's the current code: <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'dbusername'); define('DB_PASSWORD', 'dbpassword'); define('DB_DATABASE', 'dbname'); $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($username == '' && $pass == ''){ // both are empty $errmsg_arr[] = 'Username and password are missing. You must enter both or the other one.'; $errflag = true; } 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) { $qrytable1="SELECT username, dbimages, textdata FROM images_list WHERE username='$username'"; $result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error()); while ($row = mysql_fetch_array($result1)) { header('Content-Type: image/jpeg'); echo $row['image']; echo "<p id='textdata'>"; echo $row['textdata'] . "</p>"; } } } } ?> Any help would be much appreicated. thanks in advance.
-
Problem of print the images from mysql database
mark103 replied to mark103's topic in PHP Coding Help
please can someone help?????? -
Hi guys, I have a little trouble right here. I have uploaded the images and stored in mysql database. When I get access to my website, the images doesn't print out which it displayed and looks like this: How I can print the images from mysql database when I uploaded the images? Here's the current code: <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'dbusername'); define('DB_PASSWORD', 'dbpassword'); define('DB_DATABASE', 'dbname'); $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($username == '' && $pass == ''){ // both are empty $errmsg_arr[] = 'Username and password are missing. You must enter both or the other one.'; $errflag = true; } 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) { $qrytable1="SELECT username, dbimages FROM images_list WHERE username='$username'"; $result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error()); while ($row = mysql_fetch_array($result1)) { echo "<p id='dbimages'>"; echo $row['dbimages'] . "</p>"; } } } ?> Any help would be much appreicated. thanks in advance
-
thanks for your quick responded. i have replaced the code you have posted, but now I am getting this: There are 2 Users Online right nowError: Query was empty. i want to remove or even hide the Error: Query was empty, but i can't find where the problem is occuring. any idea?
-
Hi guys, I have a bit of a problem with print out the rows from mysql database. I am trying to count how many rows there are in a table, but I get this: There are 2 Users Online right nowThere are 2 Users Online right nowError: Query was empty I want to print out something like this: There are 2 Users Online right now <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'dbusername'); define('DB_PASSWORD', 'dbpass'); define('DB_DATABASE', 'dbname'); $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']); if($username == '' && $pass == ''){ // both are empty $errmsg_arr[] = 'Username are missing.'; $errflag = true; } 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 (count($insert)>0) { $names = implode(',',$insert); if($username == 'all') { $names = implode(',',$insert); $result = mysql_query("SELECT * FROM Online_Users"); $num_rows = mysql_num_rows($result); while ($row = mysql_fetch_array($result)) { echo "There are $num_rows Users Online right now"; } if (!mysql_query($sql,$link)) { die('Error: ' . mysql_error()); } } } ?> Any advice would be much appreicate. Thanks, Mark
-
Hi guys, I have a bit of trouble as I am trying to extact the data from mysql database when I enter the url as something like this: http://www.mysite.com/login.php?user=test&pass=test <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'myuser'); define('DB_PASSWORD', 'mypass'); 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)); } $user = clean($_GET['user']); $pass = clean($_GET['pass']); $login = clean($_GET['login']); if($user == '' && $pass == ''){ // both are empty $errmsg_arr[] = 'Both name and email are missing. You must enter one or the other.'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />',$errmsg_arr); } else { $insert = array(); if(isset($_GET['user'])) { $insert[] = 'user = \'' . clean($_GET['user']) .'\''; } if(isset($_GET['pass'])) { $insert[] = 'pass = \'' . clean($_GET['pass']) . '\''; } if(isset($_GET['login'])) { $insert[] = 'login = \'' . clean($_GET['login']) . '\''; } if (count($insert)>0) { $names = implode(',',$insert); if(isset($user) && isset($pass)) { $query = "SELECT username, LoggedUser FROM Login WHERE username='$user'"; $result=mysql_query($query) or die('Error:<br />' . $qry . '<br />' . mysql_error()); echo "<p id='LoggedUser'>"; echo $row['LoggedUser'] . "</p>"; } elseif(isset($user) && isset($login)) { $sql="UPDATE Login SET {$login} where username='{$user}'"; echo "<p id='LoggedUser'>"; echo $row['LoggedUser1'] . "</p>"; } } } ?> when I entered the url, there are empty array which it did not filled on the webpage. I want to extact the data from the database when I enter the url like on above. Please can you help? Thanks, Mark