Gossamer Forum
Home : Products : DBMan : Customization :

procedure returns oposite value?

Quote Reply
procedure returns oposite value?
Please help...

ok something odd is happening, and I can't figure it out. I'm new to perl. any help would be GREATLY apreciated:

I have altered the htlp.pl html_record procedure to return rows of a table instead of a table per record. This works fine.

then I went and added an if statement to the html_record so that within that table it would decide:
Code:
if ($rec{'show_email'} eq "Yes")
{
print qq|
<TD><A HREF="mailto:$rec{'email'}>$rec{'email'}</A></TD>
|;;
}
else
{
print qq|
<TD>Hidden</TD>
|;;
}

In all but one case this works fine. When html_record is called, it lists out the table and those records with show_email = yes have a clickable email link....those with show_email = No (else) display the word "hidden"

HOWEVER if html_record is called from a search form (ie any other method than "list all) AND the database field "show_email" is specified as a search parameter...the results table is correctly created except that those with show_email = Yes list "Hidden" and those with show_email = No list the email address.

Every search will work correctly unless the user includes the "show_email" field as a search paramter. If they do, then it appears (from the result table built in html_record) that each record has the opposite value in "show_email" that it actually does.

Please help!

[This message has been edited by David Meade (edited April 29, 2000).]
Quote Reply
Re: procedure returns oposite value? In reply to
Perhaps the extra semicolons are messing things up a bit. Try this and see if it works.

In sub html_record_form or sub html_record_long use:

|;
if ($rec{'show_email'} eq "Yes") {
print qq|
<TD><A HREF="mailto:$rec{'email'}>$rec{'email'}</A></TD> |;
}
else
{
print qq| <TD>Hidden</TD> |;
}
print qq|


Hope this helps Smile

[This message has been edited by LoisC (edited April 28, 2000).]
Quote Reply
Re: procedure returns oposite value? In reply to
hmm...ok that didn't work, but it did change what happens a bit and give more insight as to what is actually going on...still don't know how to fix it. A better description of what is happening is below:

when searching for records - if the field 'show_email' is included as a search variable - the propper record(s) are displayed...but the if statment mentioned in the origional post always goes to the else branch.

Its probably important to mention at this point another problem I'm having. In the form, I have used the

&build_radio_field(show_email);

to display radio buttons. The default values are Yes or No

However, when the form displays, it shows
* Yes * No 11
instead of
* Yes * No
(notice the 11)

So, it kinda' looks to me like the values being set to 'show_email' are not 'Yes' * 'No' (thus the search works, but the if statment always goes to else).

Does a radio pair assign something other than 'Yes|No' (0|1 perhaps)?

Again, THANK YOU for any help.

The code where I create the radio button on the search form is:
Code:
...
<TD ALIGN="CENTER" VALIGN="TOP" CLASS="sub1">Show Email?</TD>
<TD ALIGN="CENTER">
|;
print &build_radio_field(show_email,'Yes');
print qq|
</TD>
</TR>
...

My database def. is:
Code:
%db_def = (
FName => [0, 'alpha', 20, 25, 1, 'David', ''],
MName => [1, 'alpha', 20, 25, 1, '', ''],
LName => [2, 'alpha', 20, 25, 1, 'Meade', 'Meade'],
Age => [3, 'numer', 3, 3, 0, '', ''],
email => [4, 'alpha', 20, 30, 1, '', ''],
show_email => [5, 'alpha', 0, 3, 1, 'Yes', 'Yes|No'],
URL => [6, 'alpha', 20, 50, 0, '', ''],
URL_categ => [7, 'alpha', 0, 17, 0, '', ''],
URL_descr => [8, 'alpha', '40x3', 255, 0, '', ''],
City => [9, 'alpha', 20, 30, 0, '', ''],
State => [10, 'alpha', 2, 2, 0, '', ''],
Country => [11, 'alpha', 20, 50, 1, '', ''],
UserID => [12, 'alpha', 20, 50, 1, '', '']
);

The code I use to print the search results (and the wacky if statement) is:
Code:
print qq|
<TD>$rec{'MName'}</TD>
<TD>$rec{'City'}</TD>
<TD>$rec{'State'}</TD>
<TD>$rec{'Country'}</TD>
<TD>$rec{'Age'}</TD>
|;
if ($rec{'show_email'} eq "Yes")
{
print qq|
<TD><A HREF="mailto:$rec{'email'}>
$rec{'email'}</A></TD>
|;
}
else
{
print qq|
<TD>Hidden</TD>
|;
}
print qq|
<TD><A HREF="$rec{'URL'}">
$rec{'URL'}</A></TD>
|;
Quote Reply
Re: procedure returns oposite value? In reply to
Also, if the show_email is NOT included as a search parameter the if statment executes as expected...so the values stored are in fact "Yes" and "No" (or at least "Yes" and something else)

...sooo weird! :-)

Thanks again for any help!
Quote Reply
Re: procedure returns oposite value? In reply to
The reason for your problem is that you have

$db_bold = 1;

in your .cfg file. If you have done a search for

show_email = Yes

$rec{'show_email'} becomes

<B>Yes</B>

That, of course is not the same as

Yes

so the "if" statement doesn't work. You can fix it in a moment if you set

$db_bold = 0;

in your .cfg file.

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






Quote Reply
Re: procedure returns oposite value? In reply to
That fixed it! THANK YOU SO MUCH!

Do you have any idea why the form is creating a radio field with the options "Yes" and "No 11" (instead of "No")?

Thanks again for everyones help!

- Dave
Quote Reply
Re: procedure returns oposite value? In reply to
My guess is that your problem with the radio field is caused by a problem in %db_radio_fields in your .cfg file. If you'd like to post that portion of your .cfg file, I'll see what I can figure out.


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






Quote Reply
Re: procedure returns oposite value? In reply to
from my .cfg file:
Code:
%db_radio_fields = (
show_email => 'Yes,No'
);

the procedure in db.cgi has not been altered.
Quote Reply
Re: procedure returns oposite value? In reply to
That looks all right.

Are you sure it's within the radio field and not just on your form?

I may need to look at your database to tell you any more.


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






Quote Reply
Re: procedure returns oposite value? In reply to
pretty sure...

Here's the portion of the form that calls that procedure:

Code:
<TR>
<TD ALIGN="CENTER" CLASS="sub1">
Last Name
</TD>
<TD ALIGN="CENTER">
<INPUT TYPE="TEXT" NAME="LName" VALUE="$rec{'LName'}" SIZE="10" MAXLENGTH="30">
</TD>
<TD ALIGN="CENTER" VALIGN="TOP" CLASS="sub1">
Show Email?
</TD>
<TD ALIGN="CENTER">
|; print &build_radio_field(show_email,'Yes'); print qq|
</TD>
</TR>
Quote Reply
Re: procedure returns oposite value? In reply to
I don't know what it could be. Everything looks fine.


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






Quote Reply
Re: procedure returns oposite value? In reply to
hmm ok well I'll do some searching.

I'm new to Perl, but not to programming. And I have a good knowledge of HTML...so I might figure it out.

Thanks for all of your help with the other thing - I never would have figured that out!

- Dave

[This message has been edited by David Meade (edited April 29, 2000).]
Quote Reply
Re: procedure returns oposite value? In reply to
David:

Instead of this:

<TD ALIGN="CENTER"> |; print &build_radio_field(show_email,'Yes'); print qq| </TD>

Try this and see if it helps:

<TD ALIGN="CENTER">|; print &build_radio_field("show_email",$rec{'show_email'}); print qq| </TD>
Quote Reply
Re: procedure returns oposite value? In reply to
LoisC -

Actually I have already change it to our suggestion. This makes my form work better, but it doesn't change the face that it's showing the radio options as "Yes" and "No 11".

Thanks,
Dave
Quote Reply
Re: procedure returns oposite value? In reply to
Actually the end quote is there. I just accedentaly erased it as I pasted it here. My link actually includeds a subject:

Code:
|;
if ($rec{'show_email'} eq "Yes")
{
print qq|
<TD VALIGN="MIDDLE" ALIGN="CENTER">
<A HREF="mailto:$rec{'email'}?Subject=email from davidmeade.com">$rec{'email'}</A>
</TD>
|;
}
else
{
print qq|
<TD VALIGN="MIDDLE" ALIGN="CENTER">Hidden</TD>
|;
}
print qq|


[This message has been edited by David Meade (edited April 29, 2000).]
Quote Reply
Re: procedure returns oposite value? In reply to
David:

I was just going to edit my message and you already checked it Smile

I was going to ask you if you happened to have checked your .db file to be sure it did not somehow get corrupted. There may have been extra stuff added in that field before your corrections were made.

It never hurts to check how the data is in the database, in case somehow this # 11 is actually within the field for your show email.

Hope this helps Smile
Quote Reply
Re: procedure returns oposite value? In reply to
Actaully I hadn't checked that...so I just did...and it looks ok. There are two recrds in my databse right now. One has "Yes" and the other has "No". I did a text search on it just to be sure, and there is no ocurance of "11" anywhere in the file.


[This message has been edited by David Meade (edited April 29, 2000).]
Quote Reply
Re: procedure returns oposite value? In reply to
The only other thing that I can think of is this line may be causing problems.


<TD><A HREF="mailto:$rec{'email'}>

it's missing the ending closing ".

<TD><A HREF="mailto:$rec{'email'}">

I've seen this create weird problems, although I don't see how it would add the 11 Smile But wouldn't hurt to fix it.