1064 - You have an error in your SQL syntax
#61
Posted 28 September 2005 - 02:57 PM
I was losing all hope of fixing it after replacing the original files and restoring the database.
It turned out to be that the hosts had updated SQL and it just happened to coincide with me installing my contribution.
Thanks again!
#62
Posted 28 September 2005 - 05:24 PM
Simplyeasier, on Apr 1 2005, 11:10 AM, said:
First off - this fix is actually already recorded in the contributions section and many thanks to those who recorded it - but I don't think it is a contribution - rather a tip - Secondly the same problem has arisen for 4 people in a few days and I dare say it will happen to more as hosts migrate their mySQL databases to version 4.1.xx -
Hence I post here
If you get an error whilst creating \ modifying your database such that thro admin you delete all entries on a particular table you will likely get this message
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
followed by something like
select manufacturers_id, manufacturers_name, manufacturers_image, date_added, last_modified from manufacturers order by manufacturers_name limit -20, 20
or
select banners_id, banners_title, banners_image, banners_group, status, expires_date, expires_impressions, date_status_change, date_scheduled, date_added from banners order by banners_title, banners_group limit -20, 20
depending on which table you have deleted all records from.
To fix this
In admin/includes/classes find split_page_results.php and - BACK IT UP then find the lines
$offset = ($max_rows_per_page * ($current_page_number - 1));
$sql_query .= " limit " . $offset . ", " . $max_rows_per_page;
change to
$offset = ($max_rows_per_page * ($current_page_number - 1));
if ($offset < 0)
{
$offset = 0 ;
}
$sql_query .= " limit " . $offset . ", " . $max_rows_per_page;
MySQL 4.1.xx handles negatives correctly (by forcing an error) in the code above unlike earlier versions of MySQL.
hth
Charles
Fifty Cheers.
Went to PhP 5 MySql 4.1+ yesterday night.
Got the described 1064, this morning when checking customer/orders.
1 search for 1064, your solution, applied, works.
Yes YOU ARE a CHAMP !
thanks
Walter Kempees (NL 2.2MS2)
(I am now going to search why some have such a nice Admin interface with icons and colors and stuff, and mine is plain grey)
#63
Posted 29 September 2005 - 08:30 PM
#64
Posted 02 October 2005 - 06:59 PM
The problem I was having was in my "Specials" admin page. I did your fix and now I can use my Specials admin. Now got a new issue: On the client side, the specials.php page displays the total number of products -1. SO one less than it should. Is there another file I need modify?
Colin
#65
Posted 06 October 2005 - 02:41 PM
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 o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from orders o left join orders_total ot on (o.orders_id = ot.orders_id), orders_status s where o.orders_status = s.orders_status_id and s.language_id = '4' and ot.class = 'ot_total' order by o.orders_id DESC limit -20, 20
And I'm getting a little nerveous :-)
I don't think that there is anything I didn't try. Is there a way that someone would post the complete altered working files? Or is there a way to excude this LIMIT thing? Because I want to have the site running... It has been weeks now that I'm trying to get this fixed...
Edited by luciano, 06 October 2005 - 02:44 PM.
#66
Posted 06 October 2005 - 02:53 PM
I wonder then how the error can be in that file?
#67
Posted 06 October 2005 - 04:05 PM
CP
#68
Posted 06 October 2005 - 04:48 PM
#69
Posted 07 October 2005 - 02:49 AM
luciano, on Oct 6 2005, 04:41 PM, said:
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 o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from orders o left join orders_total ot on (o.orders_id = ot.orders_id), orders_status s where o.orders_status = s.orders_status_id and s.language_id = '4' and ot.class = 'ot_total' order by o.orders_id DESC limit -20, 20
And I'm getting a little nerveous :-)
I don't think that there is anything I didn't try. Is there a way that someone would post the complete altered working files? Or is there a way to excude this LIMIT thing? Because I want to have the site running... It has been weeks now that I'm trying to get this fixed...
The fix worked for me, should work for u too.
I'll try and trace your problem, donot despair, I'll be back.
Walter
#70
Posted 07 October 2005 - 03:05 AM
DeKemp, on Oct 7 2005, 04:49 AM, said:
I'll try and trace your problem, donot despair, I'll be back.
Walter
Found the following text in teh BUG list, it is posted by HPDL.
Basically the same fix as post #1 but more compact:
Quote
Thanks for the report, here is the official fix:
Line 67 in catalog/includes/classes/split_page_results.php must be changed from:
$this->sql_query .= " limit " . $offset . ", " . $this->number_of_rows_per_page;
to:
$this->sql_query .= " limit " . max($offset, 0) . ", " . $this->number_of_rows_per_page;
Line 38 in catalog/admin/includes/classes/split_page_results.php must be changed from:
$sql_query .= " limit " . $offset . ", " . $max_rows_per_page;
to:
$sql_query .= " limit " . max($offset, 0) . ", " . $max_rows_per_page;
#71
Posted 07 October 2005 - 09:22 AM
DeKemp, on Oct 7 2005, 05:05 AM, said:
Basically the same fix as post #1 but more compact:
Thanks for the effort Walter... but as I wrote: I tried it all and nothing helped.
Isn't it strage that even an empty split.... . php gave me the same error. That can only mean that the error is somewhere else.
So what I'm going to try now is installing one of the add-ons and if that doesn't work I delete the whole thing and start over with an easier system.
#72
Posted 07 October 2005 - 10:17 AM
<?php
if (isset($HTTP_GET_VARS['cID'])) {
$cID = tep_db_prepare_input($HTTP_GET_VARS['cID']);
$orders_query_raw = "select o.orders_id, o.customers_name, o.customers_id, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . (int)$cID . "' and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and ot.class = 'ot_total' order by orders_id DESC";
} elseif (isset($HTTP_GET_VARS['status'])) {
$status = tep_db_prepare_input($HTTP_GET_VARS['status']);
$orders_query_raw = "select o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and s.orders_status_id = '" . (int)$status . "' and ot.class = 'ot_total' order by o.orders_id DESC";
} else {
$orders_query_raw = "select o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and ot.class = 'ot_total' order by o.orders_id DESC";
}
Is there a way to exclude the DESC? Will that help? Is there a way to get rid of that LIMIT stuff? Is it possible to just generate a plain list, no split page?
#73
Posted 07 October 2005 - 10:49 AM
luciano, on Oct 7 2005, 12:17 PM, said:
<?php
if (isset($HTTP_GET_VARS['cID'])) {
$cID = tep_db_prepare_input($HTTP_GET_VARS['cID']);
$orders_query_raw = "select o.orders_id, o.customers_name, o.customers_id, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . (int)$cID . "' and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and ot.class = 'ot_total' order by orders_id DESC";
} elseif (isset($HTTP_GET_VARS['status'])) {
$status = tep_db_prepare_input($HTTP_GET_VARS['status']);
$orders_query_raw = "select o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and s.orders_status_id = '" . (int)$status . "' and ot.class = 'ot_total' order by o.orders_id DESC";
} else {
$orders_query_raw = "select o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and ot.class = 'ot_total' order by o.orders_id DESC";
}
Is there a way to exclude the DESC? Will that help? Is there a way to get rid of that LIMIT stuff? Is it possible to just generate a plain list, no split page?
you do not want to loose the DESC.
it means descending as oposed to ASC
rhis raw sql is being parsed somewhere and gets the limit added.
Still looking 4U
#75
Posted 29 November 2005 - 03:33 AM
I have done a very stupid thing whilst trying to figure out easy populate - I think I have managed to delete all my products tables - and what this means is that I can no longer access the admin panel in the browser, instead I get the error message:
1146 - Table 'cmm_com_au_-_osc6.configuration' doesn't exist
select configuration_key as cfgKey, configuration_value as cfgValue from configuration
[TEP STOP]
I am running on MySQL 3.23.58
I contacted my hosting company and they are pretty useless and offer no support at all - they did suggest however to go to MyphpAdmin and select the database->SQL and then browse for the backup file and upload which I did and I get this error in Myphp after the upload
SQL-query:
-- MySQL dump 8.23
--
-- Host: localhost Database: cmm_com_au_-_osc6
------------------------------------------------------- --
-- Server version 3.23.58
--
-- Table structure for table `address_book`
--
DROP TABLE IF EXISTS address_book
MySQL said: Documentation
#1064 - You have an error in your SQL syntax near '---------------------------------------------------------
-- Server version 3.23' at line 4
If anyone could please help me out of this mess I will be eternally grateful... I did back up, but somehow managed to destroy the database anyway...
#76
Posted 29 November 2005 - 05:07 AM
murray_simon, on Nov 29 2005, 11:33 AM, said:
I have done a very stupid thing whilst trying to figure out easy populate - I think I have managed to delete all my products tables - and what this means is that I can no longer access the admin panel in the browser, instead I get the error message:
1146 - Table 'cmm_com_au_-_osc6.configuration' doesn't exist
select configuration_key as cfgKey, configuration_value as cfgValue from configuration
[TEP STOP]
I am running on MySQL 3.23.58
I contacted my hosting company and they are pretty useless and offer no support at all - they did suggest however to go to MyphpAdmin and select the database->SQL and then browse for the backup file and upload which I did and I get this error in Myphp after the upload
SQL-query:
-- MySQL dump 8.23
--
-- Host: localhost Database: cmm_com_au_-_osc6
------------------------------------------------------- --
-- Server version 3.23.58
--
-- Table structure for table `address_book`
--
DROP TABLE IF EXISTS address_book
MySQL said: Documentation
#1064 - You have an error in your SQL syntax near '---------------------------------------------------------
-- Server version 3.23' at line 4
If anyone could please help me out of this mess I will be eternally grateful... I did back up, but somehow managed to destroy the database anyway...
I fixed it - Phew!
The error that was appearing (MySQL said: Documentation
#1064 - You have an error in your SQL syntax near '---------------------------------------------------------
-- Server version 3.23' at line 4) led me to look into the backup SQL file that I had saved and I also opened an earlier saved version and I noticed there was a difference between the two.
The backup file that would not work was like this:
-- MySQL dump 8.23---- Host: localhost Database: cmm_com_au_-_osc6 ----------------------------------------------------------- Server version 3.23.58----
an earlier version looked different so I changed it to look the same i.e.
-- MySQL dump 8.23---- Host: localhost ##Database: cmm_com_au_-_osc6# Server version 3.23.58----
The difference was the # sign before and after and getting rid of the ------------------ not sure which bit fixed it, but it now works
I re-uploaded it and hey presto it worked!! Yippppeeeee
#77
Posted 29 November 2005 - 10:06 AM
murray_simon, on Nov 29 2005, 07:07 AM, said:
The error that was appearing (MySQL said: Documentation
#1064 - You have an error in your SQL syntax near '---------------------------------------------------------
-- Server version 3.23' at line 4) led me to look into the backup SQL file that I had saved and I also opened an earlier saved version and I noticed there was a difference between the two.
The backup file that would not work was like this:
-- MySQL dump 8.23---- Host: localhost Database: cmm_com_au_-_osc6 ----------------------------------------------------------- Server version 3.23.58----
an earlier version looked different so I changed it to look the same i.e.
-- MySQL dump 8.23---- Host: localhost ##Database: cmm_com_au_-_osc6# Server version 3.23.58----
The difference was the # sign before and after and getting rid of the ------------------ not sure which bit fixed it, but it now works
I re-uploaded it and hey presto it worked!! Yippppeeeee
#78
Posted 29 November 2005 - 11:58 AM
Vger
#79
Posted 06 December 2005 - 08:54 PM
I was installing a contribution and after altering the DB i got this message:
----------------------------------------------------------------
1064 - You have an error in your SQL syntax near ' p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, ' at line 1
select p.products_image, pd.products_name, pd.products_description,, 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 = '59' order by pd.products_name
[TEP STOP]
---------------------------------------------------------------
Does anyone know what is wrong? I need to fix this fast cos im knee deep in it now that the site is down :-(
Iīm afraid of doing anything before consulting some pro help here...
#80
Posted 06 December 2005 - 09:29 PM
Itīs not fun to explain to the boss that we ainīt doing business on the web today cos I messed it up and have no clue on how to fix it :-D









