php shopping cart
free shopping cart   shopping cart software

Free Shopping Cart PHP Software


Back to Functions List
This Function Has Been Available Since:
(AFCommerce v 2.1,     Functions v 1.1)

Searches the database for relevant products based generally on user input (unless you call this function yourself with a certain set of keywords)


array = afc_do_search (keys, searchcat, searchmakes, lowrange, highrange, page, printresults)

This function searches the database for product names, product descriptions, and product captions that match the keywords (keys) passed to the function. This is the function that handles the search.php page and quick search feature.


keys (string) - This parameter is the keywords that will be searched for. This is a string, NOT an array, and you be passed to this function the same way a user would enter keywords in the search's input field.

searchcat (string) - The category id to search in. If this value is blank or is set to all, all categories will be searched.

searchmakes (string) - The manufacture id to search in. If this value is blank or is set to all, all manufactures will be searched.

lowrange (integer) - The lowest price range to search, i.e. if this is set to 10, no product with a price less than 10 will be returned.

highrange (integer) - The highest price range to search, i.e. if this is set to 100, no product with a price greater than 100 will be returned.

page (string) - The page number of results to show, if left blank it will default to page 1. This is used when showing multiple pages of results.

printresults (string) - If set to 1, the search results are printed. For example, the normal search page DOES print the results, where the relevant products feature, actually does a search to find the most relevant products, but does not print the results. Since this function returns an array of product id numbers, you can use this results in your own scripts without printing the results at all.

Return Values

Returns an array of product ids in relevancy order. So the first element of the array would be the most relevant result, the same order that results are printed when some one does a normal search on your website.

Open Source: No

Paul's Examples

There are currently no examples for this function.

Back to Functions List


(4659) Guille1Thursday December 28, 2006 at 11 : 40 am

Every time that I do a search on my site, I get these errors first, then results for the query appear below these lines. is there anything I can do to resolve this issue?.

: afc_do_search(lang/lang1.php) [function.afc-do-search]: failed to open stream: No such file or directory in /home/latinflu/public_html/store/functions/dosearch.php on line 120

Warning: afc_do_search(lang/lang1.php) [function.afc-do-search]: failed to open stream: No such file or directory in /home/latinflu/public_html/store/functions/dosearch.php on line 120

Warning: afc_do_search() [function.include]: Failed opening 'lang/lang1.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/latinflu/public_html/store/functions/dosearch.php on line 120

(147) supportadminModeratorThursday December 28, 2006 at 12 : 42 am

Hi, I wasn't going to write a patch for this because its fixed in version 2.6, but since I haven't released that yet and don't want to rush it out, I made a patch for you. Some servers look in a different file path for your language file (lang1.php in the lang directory). Normally it should be included relative to the search.php file in your main afcommerce directory, but enough people had the same problem to show me it wasn't a rare situation, and I have found the same problem with other scripts of mine, so I started using a new way to find the file. Instead of assuming the file will be where I placed it, now it tries to detect the file before it includes it.

My patch is a .tar file which can be unzipped with Winzip, or with the command line. I gave you the open source version of the file, normally the free version of afcommerce has this file encrypted, which you probably already know since you couldn't edit it. So now it looks in lang/lang1.php and if that's not found it will try ../lang/lang1.php and this has worked for 99% of people who reported the issue. I had one person say that didn't work and he modified that script to include the file from his server's path from root, which if you don't know how to find that, it is in the error message you just posted.

There is also a second way to fix this, its by far the lazy way to do things, but you won't have to download this patch, unzip it, etc. All you do is add a directory inside your functions directory named lang and upload your lang1.php to that directory. Using that way, that would be all you would have to do, and wouldn't need to change your dosearch.php file in the functions directory (which is the only file in the patch).

Patch can be found here:

For future reference, since this post will be here for a while, if you have version 2.6 or later, you wouldn't need to use this patch. Also, some people may want to download it just to have the open source file, which is fine I don't really care to much if my users get that file for free, but if the date of this post is old, the current file may have been improved since I added this patch, so I suggest not using this file unless you get the warning message reported above. As of today, the free version of 2.6 has not been released yet, I wanted it out by now but decided to add some new features for people who buy an onsite payment gateway used with the free version of AFC. Basically I am adding all on site payment forms to the checkout page, instead of the old way of having to submit the checkout page, then go to a payment form on a separate page. Version 3 has the one page checkout feature which is making every one of my users like twice as many sales because of how nice and fast the checkout process is, so even though the free version will never have all the one page checkout features, at least people who have an onsite gateway add on can have about half the benefits of our one page checkout in the free version (if they get Paypal Pro, Authorize AIM, SkipJack, or Payflow Pro).

Author Of The Free AFCommerce Shopping Cart and The Amazing Flash Website Building System

AFCommerce Documentation

High End Website DevelopmentCompletely Free
Dating Service
Copyright 2004 - 2006
AFCommerce Website
And Cart Builder