Jump to content

Recommended Posts

Image question 1

 

I want all my members to log on and all have the same default image called default.jpg and if they upload a new image then it is called userid.jpg (must be jpg) how would I do a search to see if there was an image called $mem[id].jpg and if there isn't show default.jpg?

 

Image question 2

 

Each member also has a main image which is set in the site as the same one, but with different colours etc. But in the site they can add things to the image eg. they click that they want a bandana and it adds it to the image.I know it's possible but I don't know whether it is in php...My limits are php html and css

 

Thanks for reading

Link to comment
https://forums.phpfreaks.com/topic/39184-solved-2-image-questionsproblems/
Share on other sites

For question 1:

 

If your storing it in a mysql database, you could simply set the image field's default value to default.jpg.

 

Otherwise I don't exactly understand how your doing your image checking.

 

For question 2:

 

http://www.php.net/manual/en/ref.image.php

 

You will need to have PHP's GD library installed.

For question one, you might consider looking at http://us2.php.net/manual/en/function.file-exists.php.

 

The first example provided might do what you need.

 

$file = '/images/players/a$mem[id].jpg';

if(file_exists($file)){
echo "<img src='http://www.lordoftheabyss.com/images/players/a$mem[id].jpg'>";
}else{
echo "<img src='http://www.lordoftheabyss.com/images/players/default.jpg'>";
}

 

There is a file called a1.jpg (my id is 1) and yet it still doesn't show :(

 

For question 2:

 

http://www.php.net/manual/en/ref.image.php

 

You will need to have PHP's GD library installed.

Thanks I'll take a look :)

Still didn't work...is there any other errors on my code:

$file = 'http://www.lordoftheabyss.com/images/players/a$mem[id].jpg';

if(file_exists($file)){
echo "<img src='http://www.lordoftheabyss.com/images/players/a'.$mem[id].'.jpg'>";
}else{
echo "<img src='http://www.lordoftheabyss.com/images/players/default.jpg'>";
}

Oops! :P I'm slow

alas, no joy still though.

$file = 'http://www.lordoftheabyss.com/images/players/a'.$mem[id].'.jpg';

if(file_exists($file)){
echo "<img src='http://www.lordoftheabyss.com/images/players/a'.$mem[id].'.jpg'>";
}else{
echo "<img src='http://www.lordoftheabyss.com/images/players/default.jpg'>";
}

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.