Gossamer Forum
Home : Products : DBMan : Customization :

Looking for correct syntax .

Quote Reply
Looking for correct syntax .
Looking for the correct syntax for this statement.
If either condition is not meet, forget it.
If each condition is meet then print.

Please don't try this copy of my example below, you will get a syntax error.

if (-e "$pic_location$rec{'Picture_1'}.jpg")
and
if (length($rec{'Picture_1'})>1)
do this
{
print qq|<tr><td align="CENTER" valign="MIDDLE" bgcolor="#FEE8A3"><center><b>Picture</b></center></td><td valign="MIDDLE"><ul><li><a href="javascript:display('$pic_location$rec{'Picture_1'}.jpg')">$rec{'Show_Pic_1'}</a></ul></td></tr>|;}
else forget it


Quote Reply
Re: Looking for correct syntax . In reply to
Reckon this should do it:

Code:
if (-e "$pic_location$rec{'Picture_1'}.jpg") && (length($rec{'Picture_1'})>1) {
print qq|
<tr><td align="CENTER" valign="MIDDLE" bgcolor="#FEE8A3">
<center><b>Picture</b></center></td><td valign="MIDDLE"><ul><li>
<a href="javascript:display('$pic_location$rec{'Picture_1'}.jpg')">$rec{'Show_Pic_1'}</a></ul></td></tr>
|;
}

I think you can use "and" as well as "&&".

Cheers,
adam
Quote Reply
Re: Looking for correct syntax . In reply to
Hmmmm, thats what I tried to begin with, && or and, but still comes up with syntax error with && or and. I tried inclosing the whole thing with ( ), no error but also no pic even though both conditions where met. I know there is something missing, but still a novice on CGI. We keep trying though...
Quote Reply
Re: Looking for correct syntax . In reply to
Just a couple of little things. Use

if ((-e "$pic_location$rec{'Picture_1'}.jpg") and (length($rec{'Picture_1'})>1)) {

for your first line. That will get rid of your syntax error.

As for the picture not showing up, make sure your variables are correct. I have had better luck by not including the last "/" in the path variable.

So you would have
$pic_location = "/home/public/graphics";

and

"$pic_location/$rec{'Picture_1'}.jpg"



------------------
JPD





Quote Reply
Re: Looking for correct syntax . In reply to
Thanks JP,
The "/" was part of the problem. The other was I have to make 2 variables for the path, one http://www, for the java call, and the other the root usr/www/htdocs for the "if (e-", all works now, thanks all.
'http://www.hillcountry-property.com/cgi-hillcountry-property/dbman/db.cgi?db=ranch&uid=default&ID=4001&format=long&view_records=1'


if ((length($rec{'Picture_1'})>1) and (-e "$pic_location/$rec{'Picture_1'}.jpg")) {
print qq|<tr><td align="CENTER" valign="MIDDLE" bgcolor="#FEE8A3"><center><b>Picture(s)</b></center></td><td valign="MIDDLE"><ul><li><a href="javascript:display('$pic_location_ja/$rec{'Picture_1'}.jpg')">$rec{'Show_Pic_1'}</a></ul></td></tr>|;}