Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Different folders in different URLs

Hello there, i have a general question. I have 2 domains sites:

domain1.com (master) and domain2.com (secondady)

The 2 domains (domain1.com and domai2.com) share the same mysql database. In the database i have products, and a table called images that saves the images size, path, etc.

So in the domain2.com to see the product images i add in the source image the domain1.com/pathimage/ (this because when i create a new product this will save in the hosting of domain1.com.

But i have a problem, if i create a product in the domain2.com it saves everything in the database whit no problem, but the problem is that it creates the folder image and saves the image in the hosting of domain2.com. So what i was thinking is in the image src path create a if statement to see if there is a image in a folder of domain1.com and if there isnt choose folder in the domain2.com. But i have no ideia if there is a way to tell php if a image is broken are not, can someone tell me if there is?

Sorry for my english, hope i could be clear what im trying to say.

Regards

1 Answer

Hello, i found the solution, ill leave here for someone that is having the same issue somiliar

<img src="your_image_source" onerror="this.src='/path/to/local/file'">