Just wondered, I have the following code:
<a href="<?=$row->aw_deep_link?>">
<?php if (file_exists($_SERVER['DOCUMENT_ROOT'] . 'images/products/' . $row->strId . '.jpg')):?>
<img alt="<?=$row->my_brand . ' ' . $row->line . ' ' . $row->my_product . ' - ' . $row->size.$row->unit?>" height="170" itemprop="image" src="<?=base_url() . 'images/products/' . $row->strId?>.jpg" width="170">
<?php else:?>
<img alt="<?=$row->my_brand . ' ' . $row->line . ' ' . $row->my_product . ' - ' . $row->size.$row->unit?>" height="170" itemprop="image" src="<?=$row->aw_image_url?>" width="170">
<?php endif;?>
</a>
Up until last night, this was performing perfectly; this morning - it's stopped, out of the blue and automatically defaults to the
else
clause.
Has something changed with PHP?
You don't give enough info for anyone to give you the answer, but I would suggest checking:
echo $_SERVER['DOCUMENT_ROOT'];
to find out. $row->strId
still valid? $row->strId.jpg
in the directory and are they readable by your user? Assuming that file_exists
is broken is the wrong place to start, check your variables that are being used to construct the file name.
If no files or scripts were changed that you know of (including if the image file is still actually there) then it could have been a server change / update which has caused an error.
My suggestion would be to run some simple tests in a separate file Ie check the value of your $_SERVER['DOCUMENT_ROOT']
variable, check for the existence of the directory containing your image, then check for the existence of the image.
If you're 100% sure you have changed nothing on the server, I'd suggest contacting your host.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.