Gossamer Forum
Home : Products : Links 2.0 : Customization :

Problem with the code

Quote Reply
Problem with the code
Hello all,

I just found the one topic talk about search by field, but i think the code is something wrong coz of new update forum:

Quote:
Subject: Re: Wanted: mod for search on specific fields Can't Post

--------------------------------------------------------------------------------

Ok. Here are semi- step by step instructions.

Open up search.cgi

under:
# Go through the database.
open (DB, "<$db_file_name") or &cgierr("error in search. unable to open database: $db_file_name. Reason: $!");
flock (DB, 1) if ($db_use_flock);
LINE: while (<DB> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = &split_decode($_);
$grand_total++;

add:

if ($in{'category'}){
($in{'category'} eq $valuesUnrecognized tag '$db_category') or next LINE;
}

Make the category in $in{'category'} set to the term you send in through the site_html for searches. Make the category in $db_category equal to the field in the database.

You can add as many fields as you like.

Now open site_html.pl

In sub site_html_search, add:

<select name=database_field><option>option 1<option>option 2<option>etc....</select>

Set database_field to the name you used in search.cgi for category in the statement $in{'category'}

Everything should work now.

Will somebody tell me what the real code for this $valuesUnrecognized

Please help and thanks.

Quote Reply
Re: Problem with the code In reply to
this part
$valuesUnrecognized tag '$db_category'
should be
$values[$db_category]


Lavon Russell
LookHard Mods
lavon@lh.links247.net
Quote Reply
Re: Problem with the code In reply to
Thanks BMxer,

Well, I just see the same code over there, maybe this forum cannot trace the '[]' as a code, do something please :(

Quote Reply
Re: Problem with the code In reply to
ok try
$valuesUnrecognized tag '$db_category'
should be
$values[$db_category]
I think i had markup on
Lavon Russell
LookHard Mods
lavon@lh.links247.net
Quote Reply
Re: Problem with the code In reply to
Hi Bmxer,

I try the code but still no luck, can somebody tell me what the problem to my code .. i post it below:

In search.cgi, below:

# Go through the database.
open (DB, "<$db_file_name") or &cgierr("error in search. unable to open database: $db_file_name. Reason: $!");
flock (DB, 1) if ($db_use_flock);
LINE: while (<DB>) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = &split_decode($_);
$grand_total++;[/code]
I add:

if ($in{'id'}){
($in{'$id'} eq $values[$db_id]) or next LINE;
}
if ($in{'age'}){
($in{'age'} eq $values[$db_age]) or next LINE;
}
if ($in{'sex'}){
($in{'$sex'} eq $values[$db_sex]) or next LINE;
}
if ($in{'state'}){
($in{'state'} eq $values[$db_state]) or next LINE;
}

In links.def i add, below:

# Field Number of some important fields. The number is from %db_def above
# where the first field equals 0.
$db_category = 4; $db_modified = 3; $db_url = 2;
$db_hits = 8; $db_isnew = 9; $db_ispop = 10;
$db_contact_name = 6; $db_contact_email = 7; $db_title = 1;
$db_votes = 12; $db_rating = 11; $db_mail = 13;

I add:

$db_age = 14; $db_sex = 15; $db_state = 18;
$db_id = 0;

and at home.html i add:

<form action="<%db_cgi_url%>/search.cgi" method="GET">
<input type="text" size=28 name="query">
<select name=sex><option value=""><option>Female<option>Male</select>
<select name=id><option value=""><option>Test1<option>Test2</select>
<select name=state><option value=""><option>Test1<option>Test2</select>
<select name=age><option value=""><option>Test1<option>Test2</select>
</form>

Please help and thanks.
Quote Reply
Re: Problem with the code In reply to
Look at the code more closely - you have tons of unrecognised tag errors.


Quote Reply
Re: Problem with the code In reply to
 
$values[$db_category]

Quote Reply
Re: Problem with the code In reply to
Hi Paul,

Actually the code loook like this:

if ($in{'id'}){
($in{'id'} eq $values[$db_id]) or next LINE;
}
if ($in{'sex'}){
($in{'sex'} eq $values[$db_sex]) or next LINE;
}
if ($in{'age'}){
($in{'age'} eq $values[$db_age]) or next LINE;
}
if ($in{'state'}){
($in{'state'} eq $values[$db_state) or next LINE;
}

This becoz of bugs in this new forum. Please help
Post deleted by PaulWilson In reply to
Quote Reply
Re: Problem with the code In reply to
Arghhhhh !!!!

Why this new forum so sucks ahhhhhhhh ????
I view my post before i post message and the code are very well, but when i post it, all the code are unrecognised and the error is valuesUnrecognized tag.

Paul, actually the word is $values[$db_id]) etc etc and not like i posted above, Please help.
Quote Reply
Re: Problem with the code In reply to
 
$values[$db_id] <<--- look like this, i have no idea if this forum will detect the $valuesUnrecognized tag again ...hmmmm

Quote Reply
Re: Problem with the code In reply to
ok, word of advice, when you turn markup off on the main reply page, and type [text] it just prints that, but when you click preview post, it turns markup back on so you have to turn it off twice. that doesn't seem like a bug to me.


Lavon Russell
LookHard Mods
lavon@lh.links247.net
Quote Reply
Re: Problem with the code In reply to
Ok, Thanks Bmxer & Paul, i post it all over again:

I try the code but still no luck, can somebody tell me what the problem to my code .. i post it below:

In search.cgi, below:

# Go through the database.
open (DB, "<$db_file_name") or &cgierr("error in search. unable to open database: $db_file_name. Reason: $!");
flock (DB, 1) if ($db_use_flock);
LINE: while (<DB>) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = &split_decode($_);
$grand_total++;

I add:

if ($in{'id'}){
($in{'$id'} eq $values[$db_id]) or next LINE;
}
if ($in{'age'}){
($in{'age'} eq $values[$db_age]) or next LINE;
}
if ($in{'sex'}){
($in{'$sex'} eq $values[$db_sex]) or next LINE;
}
if ($in{'state'}){
($in{'state'} eq $values[$db_state]) or next LINE;
}

In links.def i add, below:

# Field Number of some important fields. The number is from %db_def above
# where the first field equals 0.
$db_category = 4; $db_modified = 3; $db_url = 2;
$db_hits = 8; $db_isnew = 9; $db_ispop = 10;
$db_contact_name = 6; $db_contact_email = 7; $db_title = 1;
$db_votes = 12; $db_rating = 11; $db_mail = 13;

I add:

$db_age = 14; $db_sex = 15; $db_state = 18;
$db_id = 0;

and at home.html i add:

<form action="<%db_cgi_url%>/search.cgi" method="GET">
<input type="text" size=28 name="query">
<select name=sex><option value=""><option>Female<option>Male</select>
<select name=id><option value=""><option>Test1<option>Test2</select>
<select name=state><option value=""><option>Test1<option>Test2</select>
<select name=age><option value=""><option>Test1<option>Test2</select>
</form>

Please help and thanks.
Quote Reply
Re: Problem with the code In reply to
Use:

($in{$id} eq $values[$db_id]) or next LINE;

instead of:

($in{'$id'} eq $values[$db_id]) or next LINE;

Um this HTML is wrong too:

<select name=sex><option value=""><option>Female<option>Male</select>
<select name=id><option value=""><option>Test1<option>Test2</select>
<select name=state><option value=""><option>Test1<option>Test2</select>
<select name=age><option value=""><option>Test1<option>Test2</select>


Last edited by:

PaulWilson: Sep 8, 2001, 8:30 AM
Quote Reply
Re: Problem with the code In reply to
YES!!!!!! Thanks Paul

Its totally work now:

In search.cgi, below:

# Go through the database.
open (DB, "<$db_file_name") or &cgierr("error in search. unable to open database: $db_file_name. Reason: $!");
flock (DB, 1) if ($db_use_flock);
LINE: while (<DB>) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = &split_decode($_);
$grand_total++;

I add:

if ($in{'id'}){
($in{$id} eq $values[$db_id]) or next LINE;
}
if ($in{'age'}){
($in{age} eq $values[$db_age]) or next LINE;
}
if ($in{'sex'}){
($in{$sex} eq $values[$db_sex]) or next LINE;
}
if ($in{'state'}){
($in{state} eq $values[$db_state]) or next LINE;
}

In links.def i add, below:

# Field Number of some important fields. The number is from %db_def above
# where the first field equals 0.
$db_category = 4; $db_modified = 3; $db_url = 2;
$db_hits = 8; $db_isnew = 9; $db_ispop = 10;
$db_contact_name = 6; $db_contact_email = 7; $db_title = 1;
$db_votes = 12; $db_rating = 11; $db_mail = 13;

I add:

$db_age = 14; $db_sex = 15; $db_state = 18;
$db_id = 0;

and at home.html i add:

<form action="<%db_cgi_url%>/search.cgi" method="GET">
<input type="hidden" name="bool" value="or">
<input type="text" size=28 name="query">
<select name=sex><option value=""></option><option>Female</option><option>Male</option></select>
<select name=id><option value=""></option><option>0001</option><option>0002</option></select>
<select name=state><option value=""></option><option>NY</option><option>ST</option></select>
<select name=age><option value=""><option>20</option><option>21</option></select>
</form>


Thanks again Paul

Post deleted by PaulWilson In reply to