• You are not logged in. | Login

Post a reply

  • Index
  •  » Help me!
  •  » images don't display after using include()

November 14, 2006 10:01 pm

IBdaMac
Member
Ranks

images don't display after using include()

Ok, now that my sessions thing is figured out, I've got another problem.

The user's profile page uses an include statement -

include("users/profile.php");

The php seems to work fine, but none of the uploaded images are displaying on the page!  I think theres a problem with the path to the images, but I can't figure it out.

In profile.php, to show an image I have:

<?php $img_path = 'images/' . get_user_image($x); ?>
<img src=<?php echo $img_path;?> alt='' border='0' \>

profile.php gets included in /my_profile.php, and the images are in /users/images/

Any ideas?


 

 

November 14, 2006 10:04 pm

sam43inwood
Member
Ranks

Re: images don't display after using include()

you forgot the quotes in the img tag

<img src=<?php...?> alt=''>

should be:

<img src="<?php ... ?>" alt=''>

 

 

November 14, 2006 10:09 pm

phppat
Member
Ranks

Re: images don't display after using include()

sam43inwood is right, but that's not all of it.

When you use an include() statement, the included file is processed as if it was in the CWD (current working directory), which is just / when you're including it in /my_profile.php

So, where profile.php is looking for the 'images' folder, it's looking for /images/ instead of /users/images/

You should use an absolute path in profile.php like this:

<?php $img_path = "/users/images/" . get_image($x); ?>

or even use the full URL to the image:

<?php $img_path = "http://yoursite.com/users/images/" . $image; ?>

Hope that helps.


PHP monster

 

 
  • Index
  •  » Help me!
  •  » images don't display after using include()
  • Actions
  • Top