Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Mysql error '1064 - You have an error in your SQL syntax;


denzel2364

Recommended Posts

hi there

 

i have the 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 '-6, 6' 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 -6, 6"

 

 

i know normally it is an easy fix with default oscommerce because ive sorted the issue out before. its created because i have deleted all the 'specials'

However when i have to change the php in "admin/includes/classes/split_page_results.php" i have a template so therefore it isnt that simple.

 

i have:

 

"$offset = ($this->number_of_rows_per_page * ($this->current_page_number - 1));

 

$this->sql_query .= " limit " . $offset . ", " . $this->number_of_rows_per_page;

}

 

 

 

which is my modified php (for template reasons) and need to encorporate the solution to stop the error. i have found on a site that

 

 

 

"$offset = ($max_rows_per_page * ($current_page_number - 1));

if ($offset < 0)

{

$offset = 0 ;

}

$sql_query .= " limit " . $offset . ", " . $max_rows_per_page;"

 

 

sorts the problem out but its different so i need someone to look at and inform me what to change so it works. Can you help?

Link to comment
Share on other sites

Try changing this

if ($offset < 0)
{
$offset = 0;
}
$sql_query .= " limit " . $offset . ", " . $max_rows_per_page;"

to this

$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

Link to comment
Share on other sites

Try changing this
if ($offset < 0)
{
$offset = 0;
}
$sql_query .= " limit " . $offset . ", " . $max_rows_per_page;"

to this

$sql_query .= " limit " . max($offset,0) . ", " . $max_rows_per_page;"

 

Jack

 

 

unfortunately i couldnt get it to work,

 

it came up with

 

"Parse error: syntax error, unexpected T_STRING in /home/sketchba/public_html/shop/includes/classes/split_page_results.php on line 79"

Link to comment
Share on other sites

Try downloading the lastest oscommerce package and compare your code to what is in it.

 

Jack

 

do you mean the 2.2 Oscommerce. i have backup to a previous site i made. ill have a go at comparing

Link to comment
Share on other sites

If your site has the latest changes, then that would work. But it can be a 2.2 site and not have the latest code so you should download the package if there is any doubt.

 

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

Link to comment
Share on other sites

  • 3 weeks later...
If your site has the latest changes, then that would work. But it can be a 2.2 site and not have the latest code so you should download the package if there is any doubt.

 

Jack

 

 

it is a 2.2 site. Where do i find the latest package?

Link to comment
Share on other sites

That's not a working shop so you shouldn't use it. The latest MS2 package can be obtained from the above Solutions->Downloads menu item.

 

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

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...