davlun Posted April 18, 2008 Share Posted April 18, 2008 Hello, Just installed the latest download through Fantastico, surprise it was 2.2 MS2. I installed the CCGV (trad) module and then the RMA module. Encountered/fixed an error with my server as follows, if I should have done this a diff way let me know, otherwise seems to be working fine: 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.returns_id, o.returns_status, o.customers_name, o.contact_user_name, o.rma_value, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.return_reason_name, op.final_price, o.returns_date_finished, rs.returns_status_name from returned_products o left join returns_products_data op on (o.returns_id = op.returns_id), return_reasons s , returns_status rs where o.returns_reason = s.return_reason_id and s.language_id = '1' and o.returns_status = rs.returns_status_id order by o.returns_id DESC limit -20, 20 In my case, mysql was not like the minus 20, generated in the admin\includes\classes\split_page_results.php. so i changed this: class splitPageResults { function splitPageResults(&$current_page_number, $max_rows_per_page, &$sql_query, &$query_num_rows) { if (empty($current_page_number)) $current_page_number = 1; $pos_to = strlen($sql_query); $pos_from = strpos($sql_query, ' from', 0); $pos_group_by = strpos($sql_query, ' group by', $pos_from); if (($pos_group_by < $pos_to) && ($pos_group_by != false)) $pos_to = $pos_group_by; $pos_having = strpos($sql_query, ' having', $pos_from); if (($pos_having < $pos_to) && ($pos_having != false)) $pos_to = $pos_having; $pos_order_by = strpos($sql_query, ' order by', $pos_from); if (($pos_order_by < $pos_to) && ($pos_order_by != false)) $pos_to = $pos_order_by; $reviews_count_query = tep_db_query("select count(*) as total " . substr($sql_query, $pos_from, ($pos_to - $pos_from))); $reviews_count = tep_db_fetch_array($reviews_count_query); $query_num_rows = $reviews_count['total']; $num_pages = ceil($query_num_rows / $max_rows_per_page); if ($current_page_number > $num_pages) { $current_page_number = $num_pages; } $offset = ($max_rows_per_page * ($current_page_number - 1)); $sql_query .= " limit " . $offset . ", " . $max_rows_per_page; } to this, to add a check to set to zero if negative, see ALL CAPS COMMENT FOR MY CHANGE class splitPageResults { function splitPageResults(&$current_page_number, $max_rows_per_page, &$sql_query, &$query_num_rows) { if (empty($current_page_number)) $current_page_number = 1; $pos_to = strlen($sql_query); $pos_from = strpos($sql_query, ' from', 0); $pos_group_by = strpos($sql_query, ' group by', $pos_from); if (($pos_group_by < $pos_to) && ($pos_group_by != false)) $pos_to = $pos_group_by; $pos_having = strpos($sql_query, ' having', $pos_from); if (($pos_having < $pos_to) && ($pos_having != false)) $pos_to = $pos_having; $pos_order_by = strpos($sql_query, ' order by', $pos_from); if (($pos_order_by < $pos_to) && ($pos_order_by != false)) $pos_to = $pos_order_by; $reviews_count_query = tep_db_query("select count(*) as total " . substr($sql_query, $pos_from, ($pos_to - $pos_from))); $reviews_count = tep_db_fetch_array($reviews_count_query); $query_num_rows = $reviews_count['total']; $num_pages = ceil($query_num_rows / $max_rows_per_page); if ($current_page_number > $num_pages) { $current_page_number = $num_pages; } $offset = ($max_rows_per_page * ($current_page_number - 1)); if ($offset < 0) { $offset = 0; } // <<<<<<<<<< ADDED THIS LINE HERE <<<<<<<<<<<< $sql_query .= " limit " . $offset . ", " . $max_rows_per_page; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.