You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.
Hi Nick
I add the code as listed in your first post on here and made the change in the sql statement and added the . to it
?????
Offline
Please post the relevant portion of code that you have. Thank you.
Please post actual code. I want to make sure you didn't miss something. Your last statement is correct, but it seems like you've missed something if it's not working.
Offline
Hi Nick,
I also have had problems with this mod, followed the code and when I do a search it just comes up blank, no results or writing .
I have the SEO mod installed on my cart will this make a diff or does it not matter?
Cheers ;-) ,
Steve
Offline
SEO doesn't matter. If somebody could post the code they're actually using and the error message in the page source of the results page (if there is one) I can help...
Offline
Hi Nick,
When I use this mod I just get the ste_layout and a blank screen where the search out put is ment to be, I dont get any sql errors ,
If you could and it would be a great help is display the line numbers where the text needs to be changed
IE:
line 256 change this to this
line 528 change this to this
[if you know what i mean ]
Cheers ;-) ,
Steve
Offline
Here's diff output:
32,34d31 < $fd_minprice = $q->param('minprice'); < $fd_maxprice = $q->param('maxprice'); < 308c305 < $sql_statement = ste_prod_searchsql_proc('SELECT COUNT(*) FROM product','',$fd_searchstr,$searchopr,$fd_searchtyp,$fd_minprice,$fd_maxprice); --- > $sql_statement = ste_prod_searchsql_proc('SELECT COUNT(*) FROM product','',$fd_searchstr,$searchopr,$fd_searchtyp); 571c568 < <A HREF=\"$common_url&pg=$fd_pg&startrow=$prev_startrow&searchstr=$fd_searchstr_encoded&searchrpp=$store_products_to_display_per_page&searchtyp=$fd_searchtyp_encoded&ref=$fd_ref_encoded&cat=$fd_cat_encoded&catstr=$catstring_encoded&minprice=$fd_minprice&maxprice=$fd_maxprice\">$html_previous_string</A> \| --- > <A HREF=\"$common_url&pg=$fd_pg&startrow=$prev_startrow&searchstr=$fd_searchstr_encoded&searchrpp=$store_products_to_display_per_page&searchtyp=$fd_searchtyp_encoded&ref=$fd_ref_encoded&cat=$fd_cat_encoded&catstr=$catstring_encoded\">$html_previous_string</A> \| 585c582 < <A HREF=\"$common_url&pg=$fd_pg&startrow=$next_startrow&searchstr=$fd_searchstr_encoded&searchrpp=$store_products_to_display_per_page&searchtyp=$fd_searchtyp_encoded&ref=$fd_ref_encoded&cat=$fd_cat_encoded&catstr=$catstring_encoded&minprice=$fd_minprice&maxprice=$fd_maxprice\">$html_next_string</A> --- > <A HREF=\"$common_url&pg=$fd_pg&startrow=$next_startrow&searchstr=$fd_searchstr_encoded&searchrpp=$store_products_to_display_per_page&searchtyp=$fd_searchtyp_encoded&ref=$fd_ref_encoded&cat=$fd_cat_encoded&catstr=$catstring_encoded\">$html_next_string</A> 623c620 < my ($sel,$lim,$str,$opr,$typ,$min,$max) = @_; --- > my ($sel,$lim,$str,$opr,$typ) = @_; 625c622 < my $sql_statement = "("; --- > my $sql_statement = ""; 738,761c735 < $where .= ")"; < < if ($min ne "") { < < $min_quoted = database_quote('product',$min); < $psr_quoted = database_quote('product','R'); < $pss_quoted = database_quote('product','R'); < < $where .= " AND ((product_regprice>$min_quoted AND product_pricestatus=$psr_quoted) OR (product_saleprice>$min_quoted AND product_pricestatus=$pss_quoted) OR (product_pricestatus<>$psr_quoted AND product_pricestatus<>$pss_quoted))"; < < } ######### End of if statement. < < if ($max ne "") { < < $max_quoted = database_quote('product',$max); < $psr_quoted = database_quote('product','R'); < $pss_quoted = database_quote('product','R'); < < $where .= " AND ((product_regprice<$max_quoted AND product_pricestatus=$psr_quoted) OR (product_saleprice<$max_quoted AND product_pricestatus=$pss_quoted) OR (product_pricestatus<>$psr_quoted AND product_pricestatus<>$pss_quoted))"; < < } ######### End of if statement. < < < $sql_statement . = " --- > $sql_statement = "
Offline
Hi all,
This is a good mod, got it to work. there is a mis type in Nicks code that stops it from working....
Change this:
my ($sel,$lim,$str,$opr,$typ,$min,$max) = @_; my $sql_statement = "(";
To this:
my ($sel,$lim,$str,$opr,$typ,$min,$max) = @_; my $sql_statement = " ";
Cheers ;-) ,
Steve
Offline
With this mod installed (I tried installing it the first time and got errors like everybody else), is it possible to have links to the search queries and display the search results?.. For Example;
and have this link take me to a page with all items under $10 ... using this mod.
I think I will try installing it again, thanks Steve for finding the bug.
Regards
Steven
Offline
:-( Did anybody installed that mod? Is there is somebody who can help me out with installation? I did not sleept past two days...
I apreciate your help...
Offline
I installed this mod with the code at the top of this post and keept getting this error message:
DISPLAY ERROR: SUBROUTINE ste_prod_disp GENERATED MESSAGE: DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND ((product_regprice<'450' AND product_pricestatus='R') OR (product_salepric' at line 2 at /library/webserver/cgi-executables/dhmc/library/common/database.pl line 623.
I did some playing with it and came up with this sollution:
changed
my ($sel,$lim,$str,$opr,$typ,$min,$max) = @_; my $sql_statement = "("; my $where = "WHERE ";
TO
my ($sel,$lim,$str,$opr,$typ,$min,$max) = @_; my $sql_statement = ""; my $where = "WHERE (";
Changed
$where .= ")"; if ($min ne "") { $min_quoted = database_quote('product',$min); $psr_quoted = database_quote('product','R'); $pss_quoted = database_quote('product','S'); $where .= " AND ((product_regprice>$min_quoted AND product_pricestatus=$psr_quoted) OR (product_saleprice>$min_quoted AND product_pricestatus=$pss_quoted) OR (product_pricestatus<>$psr_quoted AND product_pricestatus<>$pss_quoted))"; } ######### End of if statement. if ($max ne "") { $max_quoted = database_quote('product',$max); $psr_quoted = database_quote('product','R'); $pss_quoted = database_quote('product','S'); $where .= " AND ((product_regprice<$max_quoted AND product_pricestatus=$psr_quoted) OR (product_saleprice<$max_quoted AND product_pricestatus=$pss_quoted) OR (product_pricestatus<>$psr_quoted AND product_pricestatus<>$pss_quoted))"; } ######### End of if statement. $sql_statement .= " $sel $where $lim ";
NOTE CHANGES in the above code:
$pss_quoted = database_quote('product','S');
to get it to work with sales prices.
I also replaced this code in the "Html Pages & Elements > Manage Site Elements > Product Search Form" so I could input the amount, but the origanel code will work too.
CHANGED
<SELECT NAME="minprice"> <OPTION VALUE="" SELECTED>No Minimum</OPTION> <OPTION VALUE="100">(CGIVAR)currency_symbol(/CGIVAR)100.00</OPTION> <OPTION VALUE="200">(CGIVAR)currency_symbol(/CGIVAR)200.00</OPTION> <OPTION VALUE="300">(CGIVAR)currency_symbol(/CGIVAR)300.00</OPTION> </SELECT>
TO
<INPUT TYPE="TEXT" NAME="minprice" SIZE="20" VALUE="(CGIVAR)fd_minprice(/CGIVAR)"></TD>
AND CHANGED
<SELECT NAME="maxprice"> <OPTION VALUE="" SELECTED>No Maximum</OPTION> <OPTION VALUE="1000">(CGIVAR)currency_symbol(/CGIVAR)1000.00</OPTION> <OPTION VALUE="2000">(CGIVAR)currency_symbol(/CGIVAR)2000.00</OPTION> <OPTION VALUE="3000">(CGIVAR)currency_symbol(/CGIVAR)3000.00</OPTION> </SELECT>
TO
<INPUT TYPE="TEXT" NAME="maxprice" SIZE="20" VALUE="(CGIVAR)fd_maxprice(/CGIVAR)"></TD>
This mod is working now but in a search for a product with no min and a max limit of say "450.00" it returnes a list which contains an item with a price of 1071.99. I seems to be comparing the first three numbers and thinks that the 107 part of the price is lower than 450, but in a search with a min of 108 and a max of 450 it returnes the list with out the 1071.99 item.
John
Offline
This is a PS to my last post
You could also change
$where .= " AND ((product_regprice>$min_quoted AND product_pricestatus=$psr_quoted) OR (product_saleprice>$min_quoted AND product_pricestatus=$pss_quoted) OR (product_pricestatus<>$psr_quoted AND product_pricestatus<>$pss_quoted))";
TO
$where .= " AND ((product_regprice>=$min_quoted AND product_pricestatus=$psr_quoted) OR (product_saleprice>=$min_quoted AND product_pricestatus=$pss_quoted) OR (product_pricestatus<>$psr_quoted AND product_pricestatus<>$pss_quoted))";
AND CHANGE
$where .= " AND ((product_regprice<$max_quoted AND product_pricestatus=$psr_quoted) OR (product_saleprice<$max_quoted AND product_pricestatus=$pss_quoted) OR (product_pricestatus<>$psr_quoted AND product_pricestatus<>$pss_quoted))";
TO
$where .= " AND ((product_regprice<=$max_quoted AND product_pricestatus=$psr_quoted) OR (product_saleprice<=$max_quoted AND product_pricestatus=$pss_quoted) OR (product_pricestatus<>$psr_quoted AND product_pricestatus<>$pss_quoted))";
This just add the = sign so you could return results equal to or more than, and equal to or less than.
Offline
Your problem with the wrong values being returned in the search is due to the fact that the prices are string variables, rather than decimal numbers. SQL searches strings one character at a time from left to right, rather than by numeric value. You could probably resolve this with an explicit CAST statement in the SQL call to insure that the values are treated as decimals. You can read the MySQL manual page that covers variable casting . Basically, it will probably look something like:
WHERE CAST (product_regprice as DECIMAL) >= CAST ($min_quoted as DECIMAL) OR ...
I haven't tested this, so the exact syntax may be a little off, but that's the basic idea, anyway. Like I said, reference the MySQL manual at the link above for all the details and hopefully the cast functions are properly implemented in DBD::mysql. It's also possible that by sprintf formatting the input search price and the product prices in the database to 2 decimal places, it would do the proper casting implicity; but I'm not sure on that one.
Rachael
Offline
Ok thanks to Rachael and the pointer to the CAST statement I think this is working. So it goes as fellows
CHANGE
$where .= " AND ((product_regprice>=$min_quoted AND product_pricestatus=$psr_quoted) OR (product_saleprice>=$min_quoted AND product_pricestatus=$pss_quoted) OR (product_pricestatus<>$psr_quoted AND product_pricestatus<>$pss_quoted))";
TO
$where .= " AND (((product_regprice>=CAST($min_quoted as DECIMAL)) AND product_pricestatus=$psr_quoted) OR ((product_saleprice>=CAST($min_quoted as DECIMAL)) AND product_pricestatus=$pss_quoted) OR (product_pricestatus<>$psr_quoted AND product_pricestatus<>$pss_quoted))";
AND CHANGED
$where .= " AND ((product_regprice<=$max_quoted AND product_pricestatus=$psr_quoted) OR (product_saleprice<=$max_quoted AND product_pricestatus=$pss_quoted) OR (product_pricestatus<>$psr_quoted AND product_pricestatus<>$pss_quoted))";
TO
$where .= " AND (((product_regprice<=CAST($max_quoted As DECIMAL)) AND product_pricestatus=$psr_quoted) OR ((product_saleprice<=CAST($max_quoted as DECIMAL)) AND product_pricestatus=$pss_quoted) OR (product_pricestatus<>$psr_quoted AND product_pricestatus<>$pss_quoted))";
This seems to be working, I have ran several test on my site with out any problems.
John
Offline