mark103 Posted July 9, 2011 Share Posted July 9, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/241538-set-html-tags-name-for-images/ Share on other sites More sharing options...
wildteen88 Posted July 10, 2011 Share Posted July 10, 2011 if you're storing the url of the image in your database then you do not need to the following $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>";; You'd just pass $row['images'] to your img tag echo '<p id="images"><img src="' . $row['images'] . '" /></p>'; Quote Link to comment https://forums.phpfreaks.com/topic/241538-set-html-tags-name-for-images/#findComment-1240791 Share on other sites More sharing options...
mark103 Posted July 10, 2011 Author Share Posted July 10, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/241538-set-html-tags-name-for-images/#findComment-1240837 Share on other sites More sharing options...
wildteen88 Posted July 10, 2011 Share Posted July 10, 2011 That is not possible. You cannot hide the path to the image. The image will always be downloaded to the clients machine so you want be able prevent the user from grabbing the image. Quote Link to comment https://forums.phpfreaks.com/topic/241538-set-html-tags-name-for-images/#findComment-1240868 Share on other sites More sharing options...
mark103 Posted July 10, 2011 Author Share Posted July 10, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/241538-set-html-tags-name-for-images/#findComment-1240912 Share on other sites More sharing options...
mark103 Posted July 11, 2011 Author Share Posted July 11, 2011 do anyone know how to do this? Quote Link to comment https://forums.phpfreaks.com/topic/241538-set-html-tags-name-for-images/#findComment-1241045 Share on other sites More sharing options...
dcro2 Posted July 11, 2011 Share Posted July 11, 2011 If the sites these images are on aren't yours, this is what we call hotlinking. And even worse than normal hotlinking, you don't let browsers cache the images which results in more bandwidth usage for you and the site the image is on. Seriously, just don't do it. Quote Link to comment https://forums.phpfreaks.com/topic/241538-set-html-tags-name-for-images/#findComment-1241117 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.