Gossamer Forum
Home : Products : Links 2.0 : Customization :

MySQL Search with Category Search Mod?

Quote Reply
MySQL Search with Category Search Mod?
I managed to get Links to work with MySQL database today thanks to Alex's valuable help. I have a problem however. The "SQL Power Search" version of Links has a extensively modified "search.cgi" file in order to have it query MySQL correctly. I'm really confused on how to make the SQL's search.cgi file to work with "Category Searcher" mod by Edward Bownass. You see, the one that Edward Bownass have on his site works on the original version of Links and NOT the SQL Power Search version. I need some help in this if anybody knows what to change in order to have this mod work.

This is what I've done so far:

In the SQL version of search.cgi file, I added the following lines based on my comparison of the Category Search Mod-- file search.cgi.

# See if we have something to search for.
if ($in{'query'}) {
if ($in{'where'}) { # If there is a variable where, it send the data to the new search routine
&sql_searchcat();
}
else {
&search(); # Otherwise it just does a normal search.
}


Next I added a NEW routine as mentioned above called "sql_searchcat". This is how it looks:

sub sql_searchcat {
# --------------------------------------------------------
# Searches a sql table instead of the flat file..

my ($drh, $dbh, $sth, $query, $bool, $numhits, @results);

# Connect to the database
$dbh = Mysql->Connect ($sql_host, $sql_database, $sql_username, $sql_password) or &cgierr ("SQL: Unable to connect to database. Reason: $Mysql::errstr.");

# Get the Link matches..
($in{'bool'} eq "or") ? ($bool = "OR") : ($bool = "AND");
$query = qq!
SELECT * FROM $sql_search
WHERE !;
foreach $term (@search_terms) {
$query .= qq!
(!;
foreach $field (@sql_search_fields) {
$query .= qq!
$field LIKE '%$term%' OR!;
}
chop ($query); chop ($query);
$query .= qq!
) $bool!;
}
chop ($query); chop ($query); chop ($query);
$query .= qq!
ORDER BY Title !;

# Perform the Query..
$sth = $dbh->Query ($query) or &cgierr ("SQL: Unable to query database. Reason: $Mysql: b_errstr.\nQuery: $query\n");

while (@results = $sth->FetchRow) {;
push (@{$link_results{$results[$db_category]}}, @results);
}

# Temp
$link_query = $query;

# Get the Category Matches (only if we are not getting a next set of hits..)
$query = qq!
SELECT DISTINCT Category
FROM $sql_search
WHERE !;
foreach $term (@search_terms) {
$term =~ s/\s/_/g; # We replace spaces with _ as Category names don't have spaces..
$query .= qq!
Category LIKE '%$term%' $bool!;
}
chop ($query); chop ($query); chop ($query);
$query .= qq!
ORDER BY Category !;
# Perform the Query..
$sth = $dbh->Query ($query) or &cgierr ("SQL: Unable to query database. Reason: $Mysql: b_errstr.\nQuery: $query\n");
while ($category = $sth->FetchRow) {;
push (@category_results, $category);
}

# Temp
$category_query = $query;
}


OK, very long and confusing and I'm SORRY. But that's the only way I can think of to explain my problem. Anyway, what do I have to change in the new sub routine to have it work like the Edward Bownass mod?

Any help would be appreciated.

John



[This message has been edited by jmurphy (edited November 16, 1998).]
Quote Reply
Re: MySQL Search with Category Search Mod? In reply to
How did you get Links to work with mySQL? What did you edit in the sql.cfg, search.cgi etc.? Could you please go through step-by-step if possible on how you did this? It would be extremely helpful to me.

Thanks!
Quote Reply
Re: MySQL Search with Category Search Mod? In reply to
Jmurphy Would NEVER Assist anyone, he s just ask for help and left people with trouble who come after his problems he experienced... Ask ALAX or other people, they are more than to help you w/ your problems , but Jmurphy. He s only need his problems to be solved and never wish any other people to know how he did it...

GREAT Thanks to Alax for the Scripts and valuable TIPS!

If I have my site up and ready... I m more than happy to help you guys!

Thank u all!
Quote Reply
Re: MySQL Search with Category Search Mod? In reply to
I will have to vouch for you on Mr Murphy

It seems jmurphy from www.yahoosuck.com does not keep his
word and I recommend anyone dealing with this person think
twice before offering your services or products to this individual

I had an agreement with Mr. Murphy concerning his yahoosuck.com
web site as follows: For graphic development of the navigation system
and logo's I would have a banner displayed throughout the yahoosuck
web site. After spending some time and creating the graphics for his site
and countless email he does not respond.
1. Since his site is updated daily he is still actively promoting his site using my
graphics.
2. I have sent to several emails several times so he is getting the mail
3. I submitted a site to yahoosuck and it not enters yet other sites
are still being entered into the database, which concludes he is aware
of my contact.

I suggest you do not do business of any kind with this person.
Since I have had several copyright violations in the past I have explored
the copyright infringement avenue and have learned through experience to batch
copyright my graphics and content on a monthly basis.

Sine I own the copyright and original raw files and have a copy of our agreement
including all email contact we have had I will pursue the next step which
is contact from my lawyer. Anyone else having a similar problem with a
copyright infringement contact a lawyer it is inexpensive as long as you have
substantial proof. (original files and copyright registration)

I am posting here so you can actually see first hand how the process goes. And
maybe I can help avoid a possible problem for anyone else who may run into
Mr. Murphy I am also contacting InterNIC since it is obvious he has fake contact
info in his registration which is a violation of their terms.

PS: Make sure you always keep your raw files and all email contact, it is very
important to the success of your copyright case. You can also batch copyright
your new images monthly, weekly, etc. Contact the copyright office for more
information they will send you the forms you need free. Since I am a graphic
designer by trade I need to copyright a large number of images on a steady basis,
doing it monthly will save you some money.

Dave