vancomtech Posted January 27, 2007 Posted January 27, 2007 :'( Hi, First, thank you for taking the time to look at my problem. Im probably not the first to have this problem but it making me go grey! I have a few pages showing syntax errors. The first one to go was the about.PHP. I fixed this by simply replacing it with a html page i created and renamed it to about.php. But now i have others going down the same path. I deletedall the products in the specials catalog and now I cant get into it, either through my web site or admin panel. The error shows up is: Get Them While They're Hot! 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 '-9, 9' at line 1 select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from products p, products_description pd, specials s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '1' and s.status = '1' order by s.specials_date_added DESC limit -9, 9 [TEP STOP] My web site is www.vancomtech.com I used the cpanel and went to file access, and used edit on specials.php but cant for the life of me figure just where the problem is. Any help on this will be immensly appretiated! Thanks in advance James
Velveeta Posted January 27, 2007 Posted January 27, 2007 :'( Hi, First, thank you for taking the time to look at my problem. Im probably not the first to have this problem but it making me go grey! I have a few pages showing syntax errors. The first one to go was the about.PHP. I fixed this by simply replacing it with a html page i created and renamed it to about.php. But now i have others going down the same path. I deletedall the products in the specials catalog and now I cant get into it, either through my web site or admin panel. The error shows up is: Get Them While They're Hot! 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 '-9, 9' at line 1 select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from products p, products_description pd, specials s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '1' and s.status = '1' order by s.specials_date_added DESC limit -9, 9 [TEP STOP] My web site is www.vancomtech.com I used the cpanel and went to file access, and used edit on specials.php but cant for the life of me figure just where the problem is. Any help on this will be immensly appretiated! Thanks in advance James This problem can be traced back to the split pages class (includes/classes/split_page_results.php)... Around line 65 of that file, you should find a line that assigns a value to $offset... Change this line to: $offset = ($this->number_of_rows_per_page * max(0,($this->current_page_number - 1))); This way, the lowest value that can be inserted into the lower limit of the query is 0, right now, it's multiplying the number_of_rows_per_page * -1, and coming out to -9, and so it's trying to set a limit of -9 to 9 for the query results, which is throwing that sql error... Richard. Richard Lindsey
vancomtech Posted January 27, 2007 Author Posted January 27, 2007 Thank you soooo much richard!!! Really apretiate this, it worked a treat for the specials page. However I am still getting a simualar message come back when I use the admin panel. when i try to go to reports, I can see products viewd correctly, When I click on Products Purchased i get this message: Best Products Purchased No. Products Purchased 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 '-20, 20' at line 1 select p.products_id, p.products_ordered, pd.products_name from products p, products_description pd where pd.products_id = p.products_id and pd.language_id = '1' and p.products_ordered > 0 group by pd.products_id order by p.products_ordered DESC, pd.products_name limit -20, 20 [TEP STOP] And when I click on Customer Orders-Total I get: Best Customer Orders-Total No. Customers Total Purchased 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 '-20, 20' at line 1 select c.customers_firstname, c.customers_lastname, sum(op.products_quantity * op.final_price) as ordersum from customers c, orders_products op, orders o where c.customers_id = o.customers_id and o.orders_id = op.orders_id group by c.customers_firstname, c.customers_lastname order by ordersum DESC limit -20, 20 I take it they are in the same file as my specials problem? Again, I will be forever grateful for any insite. (I can see light!!!!) :D
Jack_mcs Posted January 27, 2007 Posted January 27, 2007 The fix is the same. There is a split_page_results.php file in admin too. Jack Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons
vancomtech Posted January 27, 2007 Author Posted January 27, 2007 :thumbsup: Thanks guys! now im on my way! all I have got to do now is figure out how to customise this site :'( scary for us newbies but i will eventually get there. Regards and hopefully I can return the favour or atleast help some else in the future. James
Jack_mcs Posted February 7, 2007 Posted February 7, 2007 Double check the change you made or paste that part of the code here so someone can look at it. Jack Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons
Jack_mcs Posted February 7, 2007 Posted February 7, 2007 This line $sql_query .= " limit " . $offset . ", " . $max_rows_per_page; should be $sql_query .= " limit " . max($offset, 0) . ", " . $max_rows_per_page; Jack Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons
Jack_mcs Posted February 7, 2007 Posted February 7, 2007 To be clear, it is not my code. It is a fix from the oscommerce update, which contains other fixes that should also be applied. Jack Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons
Jack_mcs Posted February 8, 2007 Posted February 8, 2007 Is this from standard oscommerce code or a contribution? Jack Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons
Velveeta Posted February 8, 2007 Posted February 8, 2007 Sorry Jack! But now.... I have a new problem. When I go to the catalog section, I get this error when clicking on a catagory that has less than 20 items (or no 2nd page). 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 'select p.products_image, pd.products_name, p.products_id, p.manufacturers_id, p' at line 1 select count(select p.products_image, pd.products_name, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from products_description pd, products p left join manufacturers m on p.manufacturers_id = m.manufacturers_id, products_to_categories p2c left join specials s on p.products_id = s.products_id where p.products_status = \'1\' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = \'1\' and p2c.categories_id = \'35\' order by pd.products_name) as total Do you know of a fix for this? Scott This doesn't look like anything I've ever seen in a standard install, but you can probably fix it like so: select count(*) as total from (select p.products_image, pd.products_name, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from products_description pd, products p left join manufacturers m on p.manufacturers_id = m.manufacturers_id, products_to_categories p2c left join specials s on p.products_id = s.products_id where p.products_status = \'1\' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = \'1\' and p2c.categories_id = \'35\' order by pd.products_name) as newtbl So you need to take the "as total" off the end, move it next to count(*), add "from", and at the end, make it "as newtbl" Richard. Richard Lindsey
Recommended Posts
Archived
This topic is now archived and is closed to further replies.