[Cialug] Conditional logic for checking a file in PHP -- continued

David Champion cialug@cialug.org
Fri, 05 Nov 2004 13:54:15 -0600


... except you should never ever put an absolute URL references in code, 
unless there's no possible other choice.

-dc

Jerry Weida wrote:

> Try this
> 
> <?
> $filename="http://hostahaven.com/photos/".$row['HH_ID'].'.jpg';
> if (fopen($filename, "r")) {
>   echo "<td width='200'><a href='$filename'>Click for photo</a>";
> } else {
>   echo "<td width='200'>No Photo Available</td>";
> }
> ?>
> 
> On Fri,  5 Nov 2004 12:29:47 -0600 (CST), Andrew Lietzow
> <alietzow@myfamily.com> wrote:
> 
>>Here is some php code that does NOT work.
>>I get this error.
>>Parse error: parse error, unexpected T_STRING, expecting '('
>>
>><?
>>if fopen("http://hostahaven.com/photos/"+$row["HH_ID"]+'.jpg'","r")
>>        then <td width="200"><a href="http://hostahaven.com/photos/<?= $row["HH_ID"] ?>.jpg"</a>
>>                Click for photo</td>
>>        else <td width="200">No Photo Available</td>
>>?>
>>
>>If you want to refer me to a book that has good examples of this, or preferrably an online resource, that would be great.
>>
>>TIA for any help,
>>Andrew