Re: Daily pic problem



shror wrote:
On Sep 20, 3:45 pm, Jerry Stuckle <jstuck...@xxxxxxxxxxxxx> wrote:
shror wrote:
Hi every body,
am trying to create a php script that get a daily picture but am
having a problem with that,
here is the code am using:
<?php
$date = date("Y-m-d");
echo "";
$ext = ".jpg";
$photo = "/DailyPic/photos/thumbs/$date". $ext ;
switch ($photo){
case "file_exisits ($photo)":
echo "<a href='/DailyPic/photos/$date". $ext ."'>";
echo "<img src='";
echo "/DailyPic/photos/thumbs/$date". $ext ;
echo "'></a>";
break;
default:
echo "<a href='/DailyPic/photos/default.jpg'>";
echo "<img src='";
echo "/DailyPic/photos/thumbs/default.jpg";
echo "'></a>";
break;
}
?>
what I get is the default image only so I need some help please.
Thanks for and support given in advance
shror
>>> switch ($photo){
>>>>> case "file_exisits ($photo)":

Doesn't work. $photo is a string (filename) and is not equal to the
result from file_exists (true/false) value. And I think you had a typo
in transcribing your code :-).

Why use a switch statement here, anyway? Just us

if (file_exists($photo)) ...

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@xxxxxxxxxxxxx
==================

Thanks Jerry for your quick response, but I have tried the if
(file_exists ($photo)) and its also giving me the default image

here is the code I used:

<?php

$date = date("Y-m-d");
echo "";
$ext = ".jpg";

$photo = "/DailyPic/photos/thumbs/$date". $ext ;
if (file_exists ($photo)){
echo "<a href='/DailyPic/photos/$date". $ext ."'>";
echo "<img src='";
echo "$photo" ;
echo "'></a>";
}
else {
echo "<a href='/DailyPic/photos/default.jpg'>";
echo "<img src='";
echo "/DailyPic/photos/thumbs/default.jpg";
echo "'></a>";
}
?>

thanks any way for any support supplied
shror


Then the file /DailyPic/photos/thumbs/$date doesn't exist.

This is an absolute path, so that will be referencing the root of your system.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================

.



Relevant Pages