Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / 1064 - syntax to use near '*) as total FROM zen_products

1064 - syntax to use near '*) as total FROM zen_products

5 Aug 2014, 9:40 AM
#1
devyani avatar

devyani

Zen Follower

Join Date:
Aug 2011
Posts:
199
Plugin Contributions:
0

Post #1 by devyani

Hi,
I am getting this error when trying to click on "new products" or "all products" link from the home page.
I am not well versed with ( or rather not at all versed with) SQL and syntaxes.
Please let me know what is the correct syntax.
Thanks. I am pasting the error exactly as it is below:

1064 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 '*) as total FROM zen_products p left join zen_manufacturers m on (p.manufacture' at line 1
in:
[select count(distinct *) as total FROM zen_products p left join zen_manufacturers m on (p.manufacturers_id = m.manufacturers_id) left join zen_products_to_categories p2c on p.products_id = p2c.products_id left join zen_products_description pd on p.products_id = pd.products_id WHERE p.products_status = 1 AND pd.language_id = 1 and p.products_date_added >=20140706]

5 Aug 2014, 10:52 AM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #2 by mc12345678

Try removing the word as that follows the right parenthesis.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

8 Aug 2014, 1:40 PM
#3
devyani avatar

devyani

Zen Follower

Join Date:
Aug 2011
Posts:
199
Plugin Contributions:
0

Post #3 by devyani

Thanks mc12345678.
But I am not able to find the file to edit. I have tried using the developer tool kit, to match the parts of the error string, no results are found. I am thinking it should be under modules/pages/ but I have checked this area and no such query with "*" is there.
Also as I pointed out this error comes with all files that needs filter. ie "all products", "new products", "featured products" , "specials"
Please let me know

8 Aug 2014, 2:05 PM
#5
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #5 by mc12345678

devyani:

Thanks mc12345678.
But I am not able to find the file to edit. I have tried using the developer tool kit, to match the parts of the error string, no results are found. I am thinking it should be under modules/pages/ but I have checked this area and no such query with "*" is there.
Also as I pointed out this error comes with all files that needs filter. ie "all products", "new products", "featured products" , "specials"
Please let me know

Regarding the particular query, you won't find the query if it contains the substituted table name ie. Zen_manufcturers, because the code more than likely uses the constant associated with that table: TABLE_MANUFACTURERS. Also spacing between words may not be exact as the query could be generated over several lines and using combinations of parts. Further the search for * at least in times past wasn't very helpful (ie. This version of ZC) try searching for maybe p2c.products_id. That one looks relatively unique enough to not appear multiple times.

I'm not sure that I could do a search of my own store to specifically identify the file. Ahh, then again, I just remembered that lat9 made a great development that would identify the file that ran the sql that caused the error. It can be found/incorporated from: http://www.zen-cart.com/showthread.php?213695-myDEBUG-Backtrace-Support-Thread

In this thread, and I have not incorporated the discussed plugin, is a reference to an earlier suggestion. That suggestion has been adopted in 1.5.3, but I don't know if the plugin incorporates it or not. Regardless, the suggestion link should take you to some code that would help you locate the problem after installation and then generating the error again.

Left the above here as part of the discussion includes why the search was not successful. Lat9 beat me to the punch. :)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

11 Aug 2014, 11:43 AM
#6
devyani avatar

devyani

Zen Follower

Join Date:
Aug 2011
Posts:
199
Plugin Contributions:
0

Post #6 by devyani

Thanks Lat9, mc12345678.
I am onto it now.
I will also reply with the "culprit" function, so that others who may have the same problem would know where to look for.
Thanks

14 Aug 2014, 5:55 AM
#7
devyani avatar

devyani

Zen Follower

Join Date:
Aug 2011
Posts:
199
Plugin Contributions:
0

Post #7 by devyani

As suggested by lat9, reposting the issue here.

I am running 1.5.1. When I click on these links :
http://bambino.co.in/index.php?main_page=products_new
http://bambino.co.in/index.php?main_page=products_all
http://bambino.co.in/index.php?main_page=specials
... etc

I get this error:

1064 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 '*) as total FROM zen_products p left join zen_manufacturers m on (p.manufacture' at line 1
in:
[select count(distinct *) as total FROM zen_products p left join zen_manufacturers m on (p.manufacturers_id = m.manufacturers_id) left join zen_products_to_categories p2c on p.products_id = p2c.products_id left join zen_products_description pd on p.products_id = pd.products_id WHERE p.products_status = 1 AND pd.language_id = 1 and p.products_date_added >=20140706]

I am not able to find the correct file to check for syntax error thru delevlopers tool kit.
Please help !

14 Aug 2014, 6:14 AM
#8
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Post #8 by simon1066

devyani:

As suggested by lat9, reposting the issue here.

I am running 1.5.1. When I click on these links :
http://bambino.co.in/index.php?main_page=products_new
http://bambino.co.in/index.php?main_page=products_all
http://bambino.co.in/index.php?main_page=specials
... etc

I get this error:

1064 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 '*) as total FROM zen_products p left join zen_manufacturers m on (p.manufacture' at line 1
in:
[select count(distinct *) as total FROM zen_products p left join zen_manufacturers m on (p.manufacturers_id = m.manufacturers_id) left join zen_products_to_categories p2c on p.products_id = p2c.products_id left join zen_products_description pd on p.products_id = pd.products_id WHERE p.products_status = 1 AND pd.language_id = 1 and p.products_date_added >=20140706]

I am not able to find the correct file to check for syntax error thru delevlopers tool kit.
Please help !

Having had a quick search through Zen's files it seems to my inexperienced eye that the file you might be looking for is the header_php.php in modules/pages/specials - for example.

I can't help thinking that with the error occurring on so many pages it might a more fundamental issue.

Simon

14 Aug 2014, 6:31 AM
#9
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Post #9 by simon1066

simon1066:

Having had a quick search through Zen's files it seems to my inexperienced eye that the file you might be looking for is the header_php.php in modules/pages/specials - for example.

I can't help thinking that with the error occurring on so many pages it might a more fundamental issue.

Just realised I was searching my own install of ZC, rather than the original code - it seems that there's a difference, probably because of my add-ons, so what I've said may not apply in the specials case. I would still think that the header_php.php files are the place to look (main_template_vars.php in the case of specials)

Simon

14 Aug 2014, 9:38 AM
#10
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #10 by mc12345678

devyani:

As suggested by lat9, reposting the issue here.

I am running 1.5.1. When I click on these links :
http://bambino.co.in/index.php?main_page=products_new
http://bambino.co.in/index.php?main_page=products_all
http://bambino.co.in/index.php?main_page=specials
... etc

I get this error:

1064 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 '*) as total FROM zen_products p left join zen_manufacturers m on (p.manufacture' at line 1
in:
[select count(distinct *) as total FROM zen_products p left join zen_manufacturers m on (p.manufacturers_id = m.manufacturers_id) left join zen_products_to_categories p2c on p.products_id = p2c.products_id left join zen_products_description pd on p.products_id = pd.products_id WHERE p.products_status = 1 AND pd.language_id = 1 and p.products_date_added >=20140706]

I am not able to find the correct file to check for syntax error thru delevlopers tool kit.
Please help !

Unfortunately it probably isn't possible to search for a series of words besides each other as the text is probably riffled with tabs, extra spaces, etc... Adding the code that was suggested above isn't providing more information after regurgitating the SQL query?

I would try to search on some basic things in that query. Like one word or expected word. For example, the word distinct. Realize that table names are provided through substitution. So FROM zen_products is created from something like: "FROM " . TABLE_PRODUCTS but there could be any number of spaces between or a carriage return, etc... Look for something as I think I suggested before that is relatively obscure in the line of the SQL. Then slowly sift through the returned data.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

14 Aug 2014, 12:26 PM
#11
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,156
Plugin Contributions:
56

Post #11 by lat9

Try making the following change to /includes/classes/split_page_results.php (starting at line 69 in an unmodified v1.5.1 version):

   if ([B]([/B]strpos($query_lower, 'distinct') || strpos($query_lower, 'group by')[B]) && $count_key != '*'[/B]) {  //-20140814-lat9-Don't use distinct when the count key is *
      $count_string = 'distinct ' . zen_db_input($count_key);
    } else {
      $count_string = zen_db_input($count_key);
    }
18 Aug 2014, 12:36 PM
#12
devyani avatar

devyani

Zen Follower

Join Date:
Aug 2011
Posts:
199
Plugin Contributions:
0

Post #12 by devyani

Thanks Simon, will look into that file.
Thanks mc12345678, I will try searching again.
Though I was more hoping that somebody will correct the syntax error for me. I have no knowledge of SQL :(
Thanks Lat9. Would try that .

18 Aug 2014, 12:50 PM
#13
devyani avatar

devyani

Zen Follower

Join Date:
Aug 2011
Posts:
199
Plugin Contributions:
0

Post #13 by devyani

And its working !!

Thank You sooooooooooo very much.
So as i understand distinct and * don't go together. In that case everybody ( who has installed split page add on) might be getting the same error. Shall I report this on their support group?

18 Aug 2014, 1:07 PM
#14
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,156
Plugin Contributions:
56

Post #14 by lat9

devyani:

And its working !!

Thank You sooooooooooo very much.
So as i understand distinct and * don't go together. In that case everybody ( who has installed split page add on) might be getting the same error. Shall I report this on their support group?
You understand correctly. Which split-page add-on did you install? You should report this change to its support group.