Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

SQL problem


El_Heso

Recommended Posts

Hi!

I have a huge problem so i hope someone can see what i have done wrong

 

My code:

 

<?php

if (isset($HTTP_GET_VARS['page']) && ($HTTP_GET_VARS['page'] > 1)) $rows = $HTTP_GET_VARS['page'] * MAX_DISPLAY_SEARCH_RESULTS - MAX_DISPLAY_SEARCH_RESULTS;

$rows = 0;

$points_query_raw = "select c.customers_firstname, c.customers_lastname, c.customers_competition_points from " . TABLE_CUSTOMERS . " c order by c.customers_competition_points DESC";

$points_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $points_query_raw, $points_query_numrows);

$points_query = tep_db_query($points_query_raw);

while ($points = tep_db_fetch_array($points_query)) {

$rows++;

 

if (strlen($rows) < 2) {

$rows = '0' . $rows;

}

?>

 

 

 

Error 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 'select c.customers_firstname, c.customers_lastname, c.customers_competition_points ' at line 1

 

select count(select c.customers_firstname, c.customers_lastname, c.customers_competition_points from customers c order by c.customers_competition_points DESC) as total

 

 

 

I have a new field in table customers where i have some points and i want to recive them from database and show them highest first

 

Hope you guys can help me

Link to comment
Share on other sites

Hi

 

Don't think error relates to code snippet you posted and according to the Error message it is more likely to be the SQL for $points_query_numrows. You need to decide what you are counting since COUNT in SQL only operates on one column. From the code snippet looks as if you are splitting results by pages so would the php function mysql_num_rows that tells number rows is a output from sql query not be an alternative?

 

Regards

 

Error 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 'select c.customers_firstname, c.customers_lastname, c.customers_competition_points ' at line 1

 

select count(select c.customers_firstname, c.customers_lastname, c.customers_competition_points from customers c order by c.customers_competition_points DESC) as total

 

 

 

I have a new field in table customers where i have some points and i want to recive them from database and show them highest first

 

Hope you guys can help me

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...