1064 sql error from mod in split_page_results.php ?
Hi i wonder if anyone can help or at least point me in the right direction, i am getting an sql syntax error when i try to access my products types page from my admin, the complete error is :
Code:
original_query=
count_query=select count(select * from zen_product_types) as total
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 * from zen_product_types) as total' at line 1
in:
[select count(select * from zen_product_types) as total ]
If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.
i have recently installed a code by limelites for spilt_page_results.php found in this thread
Code:
http://www.zen-cart.com/forum/showthread.php?t=37658
installation went fine on the client side but admin side i cannot access my product types page and just see the error as listed above.
Code:
<?php
/**
* split_page_results Class.
*
* @package classes
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: split_page_results.php 3041 2006-02-15 21:56:45Z wilt $
*/
if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
/**
* Split Page Result Class
*
* An sql paging class, that allows for sql reslt to be shown over a number of pages using simple navigation system
* Overhaul scheduled for subsequent release
*
* @package classes
*/
class splitPageResults extends base {
var $sql_query, $number_of_rows, $current_page_number, $number_of_pages, $number_of_rows_per_page, $page_name;
/* class constructor */
function splitPageResults($query, $max_rows, $count_key = '*', $page_holder = 'page', $debug = true) {
global $db;
$this->sql_query = $query;
$this->page_name = $page_holder;
if ($debug) {
echo 'original_query=' . $query . '<br /><br />';
}
if (isset($_GET[$page_holder])) {
$page = $_GET[$page_holder];
} elseif (isset($_POST[$page_holder])) {
$page = $_POST[$page_holder];
} else {
$page = '';
}
if (empty($page) || !is_numeric($page)) $page = 1;
$this->current_page_number = $page;
$this->number_of_rows_per_page = $max_rows;
$pos_to = strlen($this->sql_query);
$query_lower = strtolower($this->sql_query);
$pos_from = strpos($query_lower, ' from', 0);
$pos_group_by = strpos($query_lower, ' group by', $pos_from);
if (($pos_group_by < $pos_to) && ($pos_group_by != false)) $pos_to = $pos_group_by;
$pos_having = strpos($query_lower, ' having', $pos_from);
if (($pos_having < $pos_to) && ($pos_having != false)) $pos_to = $pos_having;
$pos_order_by = strpos($query_lower, ' order by', $pos_from);
if (($pos_order_by < $pos_to) && ($pos_order_by != false)) $pos_to = $pos_order_by;
if (strpos($query_lower, 'distinct') || strpos($query_lower, 'group by')) {
$count_string = 'distinct ' . zen_db_input($count_key);
} else {
$count_string = zen_db_input($count_key);
}
$count_query = "select count(" . $count_string . ") as total " .
substr($this->sql_query, $pos_from, ($pos_to - $pos_from));
if ($debug) {
echo 'count_query=' . $count_query . '<br /><br />';
}
$count = $db->Execute($count_query);
$this->number_of_rows = $count->fields['total'];
$this->number_of_pages = ceil($this->number_of_rows / $this->number_of_rows_per_page);
if ($this->current_page_number > $this->number_of_pages) {
$this->current_page_number = $this->number_of_pages;
}
$offset = ($this->number_of_rows_per_page * ($this->current_page_number - 1));
// fix offset error on some versions
if ($offset < 0) { $offset = 0; }
$this->sql_query .= " limit " . $offset . ", " . $this->number_of_rows_per_page;
}
/* class functions */
function display_links($max_page_links,$parameters = '') {
if ( zen_not_null($parameters) && (substr($parameters, -1) != '&') ) $parameters .= '&';
$num_pages = ceil($this->number_of_rows / $this->number_of_rows_per_page);
$pages_array = array();
for ($i=1; $i<=$num_pages; $i++) {
$pages_array[] = array('id' => $i, 'text' => $i);
}
if ($num_pages > 1) {
$display_links = zen_draw_form('pages', zen_href_link($_GET['main_page']),'get') . zen_draw_hidden_field('main_page', $_GET['main_page']);
if ($this->current_page_number > 1) {
$display_links .= '<a href="' . zen_href_link($_GET['main_page'], $parameters . $this->page_name . '=' . ($this->current_page_number - 1), 'NONSSL') . '" class="splitPageLink">' . PREVNEXT_BUTTON_PREV . '</a> ';
} else {
$display_links .= PREVNEXT_BUTTON_PREV . ' ';
}
$display_links .= sprintf('Page %s of %d', zen_draw_pull_down_menu($this->page_name, $pages_array, $this->current_page_number, 'onChange="this.form.submit();"'), $num_pages);
if (($this->current_page_number < $num_pages) && ($num_pages != 1)) {
$display_links .= ' <a href="' . zen_href_link($_GET['main_page'], $parameters . $this->page_name . '=' . ($this->current_page_number + 1), 'NONSSL') . '" class="splitPageLink">' . PREVNEXT_BUTTON_NEXT . '</a>';
} else {
$display_links .= ' ' . PREVNEXT_BUTTON_NEXT;
}
if ($parameters != '') {
if (substr($parameters, -1) == '&') $parameters = substr($parameters, 0, -1);
$pairs = explode('&', $parameters);
while (list(, $pair) = each($pairs)) {
list($key,$value) = explode('=', $pair);
$display_links .= zen_draw_hidden_field(rawurldecode($key), rawurldecode($value));
}
}
if (SID) $display_links .= zen_draw_hidden_field(zen_session_name(), zen_session_id());
$display_links .= '</form>';
} else {
$display_links = sprintf(TEXT_RESULT_PAGE, $num_pages, $num_pages);
}
return $display_links;
}
// display number of total products found
function display_count($text_output) {
$to_num = ($this->number_of_rows_per_page * $this->current_page_number);
if ($to_num > $this->number_of_rows) $to_num = $this->number_of_rows;
$from_num = ($this->number_of_rows_per_page * ($this->current_page_number - 1));
if ($to_num == 0) {
$from_num = 0;
} else {
$from_num++;
}
if ($to_num <= 1) {
// don't show count when 1
return '';
} else {
return sprintf($text_output, $from_num, $to_num, $this->number_of_rows);
}
}
}
?>
any help would be VERY WELCOME :) thanks in advance
Re: 1064 sql error from mod in split_page_results.php ?
There are two split_page_results classes. One for use in the admin and one in the catalog.
You've posted the code for the one used in the catalog, but described a problem in the admin. Did you overwrite the file with the admin version with the one containing this code? If so, you'll need to undo it.
Re: 1064 sql error from mod in split_page_results.php ?
Quote:
Originally Posted by
kuroi
There are two split_page_results classes. One for use in the admin and one in the catalog.
You've posted the code for the one used in the catalog, but described a problem in the admin. Did you overwrite the file with the admin version with the one containing this code? If so, you'll need to undo it.
wow, what a school boy error, must have gotten mixed up somehow along the way!!!!!!
thank you SO MUCH!!!!