Jump to content

set html tags name for images


mark103

Recommended Posts

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.

Link to comment
Share on other sites

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>';

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.