Re: Daily pic problem



On Sep 20, 9:04 am, shror <shahi...@xxxxxxxxx> 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

You really need to make sure that "/DailyPic/photos/" is what you
think it is. Try using opendir() and readdir() in a test script (run
through the web server, not from the command line) to make sure you
are looking where you think you are looking.

It's probably a simple matter of whether or not to have the first "/"
in your path.

Otherwise, the code you wrote that I'm quoting is fine... except that
it could be briefer.

.



Relevant Pages

  • Re: Large File Not Being Sent To Client
    ... I tried changing the php script to do fopen, fread, echo, ... The messages in the log file stop at 10MB, ... Without the header the browser is free to figure on it's own how long the data should be. ...
    (comp.lang.php)
  • Re: help! what should I do when there is a segmentation fault in my php script
    ... i also tried to insert some echo or print ... but there's not any thing but segfault in the screen. ... but some php script works well.:.those not so complex. ... What webserver program do you use? ...
    (alt.php)
  • Large File Not Being Sent To Client
    ... My company produces reports for our customers in PDF format. ... I tried changing the php script to do fopen, fread, echo, ... The messages in the log file stop at 10MB, ...
    (comp.lang.php)
  • Re: Large File Not Being Sent To Client
    ... I tried changing the php script to do fopen, fread, echo, ... After each flush, I write a message to a log ... The messages in the log file stop at 10MB, ...
    (comp.lang.php)
  • Re: first even php code
    ... > This is my first ever, ever PHP script. ... the first call would close the connection to the database, ... echo ''.tt; ... //Close the database connection ...
    (comp.lang.php)