By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,722 Members | 1,874 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,722 IT Pros & Developers. It's quick & easy.

Daily pic problem

P: n/a
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
Sep 20 '08 #1
Share this Question
Share on Google+
14 Replies


P: n/a
On Sep 20, 3:34*pm, shror <shahi...@gmail.comwrote:
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
I forgot to mention one more point,
I found this script and customized it correctly but its skipping the
if statement and only preview the default image too
http://www.free-php.net/detail/link-13.html

Thanks so much in advance

Sep 20 '08 #2

P: n/a
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.
js*******@attglobal.net
==================

Sep 20 '08 #3

P: n/a
On Sep 20, 3:45*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
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...@attglobal.net
==================
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
Sep 20 '08 #4

P: n/a
shror wrote:
On Sep 20, 3:45 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>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...@attglobal.net
==================

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.
js*******@attglobal.net
==================

Sep 20 '08 #5

P: n/a
<comp.lang.php>
<shror>
<Sat, 20 Sep 2008 06:04:48 -0700 (PDT)>
<cf**********************************@s50g2000hsb. googlegroups.com>
I have tried the if
(file_exists ($photo)) and its also giving me the default image
Untested - but it should work .
<?php

$date=date("Y-m-d");

$rambo1="DailyPic/photos/thumbs/$date" . ".jpg";
$rambo2="DailyPic/photos/photos/$date" . ".jpg";

$batman1=$rambo1;
$batman2=$rambo2;

if (!file_exists($batman1))
{
$rambo1="DailyPic/photos/thumbs/default.jpg";
$rambo2="DailyPic/photos/photos/default.jpg";
}

if (!file_exists($batman2))
{
$rambo1="DailyPic/photos/thumbs/default.jpg";
$rambo2="DailyPic/photos/photos/default.jpg";
}

$xy=getimagesize($rambo1);

print "<div align=center>";
print "<a href=$rambo2>";
print "<img src=$rambo1 width=$xy[0] height=$xy[1] border=0>";
print "</a>";
print "</div>";

?>
--
www.phpguestbook.co.uk/phpgb
(the best php guestbook on planet earth)
Sep 20 '08 #6

P: n/a
..oO(shror)
>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 ;
$photo = $_SERVER['DOCUMENT_ROOT']."/DailyPic/photos/thumbs/$date$ext";

Micha
Sep 20 '08 #7

P: n/a
On 20 Sep, 13:36, shror <shahi...@gmail.comwrote:
I found this script and customized it correctly
Err, obviously not, otherwise it would be working!
Sep 20 '08 #8

P: n/a
On Sat, 20 Sep 2008 15:14:30 +0100, PHPGB <me@privacy.netwrote:
><comp.lang.php>
<shror>
<Sat, 20 Sep 2008 06:04:48 -0700 (PDT)>
<cf**********************************@s50g2000hsb .googlegroups.com>
>I have tried the if
(file_exists ($photo)) and its also giving me the default image

Untested - but it should work .
<?php

$date=date("Y-m-d");

$rambo1="DailyPic/photos/thumbs/$date" . ".jpg";
$rambo2="DailyPic/photos/photos/$date" . ".jpg";
Oh no, not KrapKrustyKode !

--
Regards, Paul Herber, Sandrila Ltd.
Unicode characters http://www.diacrit.sandrila.co.uk/
Sep 20 '08 #9

P: n/a
Captain Paralytic wrote:
On 20 Sep, 13:36, shror <shahi...@gmail.comwrote:
>I found this script and customized it correctly
Err, obviously not, otherwise it would be working!
I hate to post a useless comment on this but this remark...it had me
laughing hard, so I must say thanks.

Scotty
Sep 21 '08 #10

P: n/a
On Sep 20, 6:34*am, shror <shahi...@gmail.comwrote:

I know it seems dumb but in cases like this it seems I would make a
tiny mistake like not labeling the dated pictures exactly as the PHP
file is trying to reference, so unless you have you might want to
verify that exactly what the $photo variable is points exactly at a
file.
Sep 22 '08 #11

P: n/a
Message-ID:
<a4**********************************@w24g2000prd. googlegroups.comfrom
transpar3nt contained the following:
>
I know it seems dumb but in cases like this it seems I would make a
tiny mistake like not labeling the dated pictures exactly as the PHP
file is trying to reference, so unless you have you might want to
verify that exactly what the $photo variable is points exactly at a
file.

But surely you would automate the naming of the pictures?
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
http://slipperyhill.co.uk - http://4theweb.co.uk
Sep 22 '08 #12

P: n/a
On Sep 20, 9:04 am, shror <shahi...@gmail.comwrote:
On Sep 20, 3:45 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
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...@attglobal.net
==================

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.

Sep 22 '08 #13

P: n/a
On Sep 21, 5:36*am, FutureShock <futuresho...@att.netwrote:
Captain Paralytic wrote:
On 20 Sep, 13:36, shror <shahi...@gmail.comwrote:
I found this script and customized it correctly
Err, obviously not, otherwise it would be working!

I hate to post a useless comment on this but this remark...it had me
laughing hard, so I must say thanks.

Scotty
Thanks every body for any support even if my questions were not that
clear and thanks for any useless quotes been submitted here , but
finally I got the problem and it was very simple that the path:
$photo = "/DailyPic/photos/thumbs/$date". $ext ;
should be like this,
$photo = "../DailyPic/photos/thumbs/$date". $ext ; the .. was the
problem and the second point was that I have to call a variable other
than the $photo so that for example I should echo "$photo2";
where $photo2 = $photo;
thanks so much and hope my problem and solution could help others
fixing their code.

shror
Sep 26 '08 #14

P: n/a
shror wrote:
On Sep 21, 5:36 am, FutureShock <futuresho...@att.netwrote:
>Captain Paralytic wrote:
>>On 20 Sep, 13:36, shror <shahi...@gmail.comwrote:
I found this script and customized it correctly
Err, obviously not, otherwise it would be working!
I hate to post a useless comment on this but this remark...it had me
laughing hard, so I must say thanks.

Scotty

Thanks every body for any support even if my questions were not that
clear and thanks for any useless quotes been submitted here , but
finally I got the problem and it was very simple that the path:
$photo = "/DailyPic/photos/thumbs/$date". $ext ;
should be like this,
$photo = "../DailyPic/photos/thumbs/$date". $ext ; the .. was the
problem and the second point was that I have to call a variable other
than the $photo so that for example I should echo "$photo2";
where $photo2 = $photo;
thanks so much and hope my problem and solution could help others
fixing their code.

shror
Shror glad to see you figure it out.
I apologize for my useless comment, most people here are very helpful.
Hopefully it was not taken personally at you, not my intention.
It's just sometimes you can't help but laugh at a sarcastic remark,
especially when I can relate to being on the receiving end of it.

Scotty.

Sep 26 '08 #15

This discussion thread is closed

Replies have been disabled for this discussion.