Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Pulling My hair out over a SQL Query


Guest

Recommended Posts

Posted

I have tried formatting this in more ways than I can count to get it to run, and I've just out of options. I even reformatted it as directed in a post that I found under proposals and suggestions and I still get an SQL error or a Parse error. When i get rid of the parse errors I get a SQL Syntax error. I'm just really need someone to look at this. I don't look good bald and I'm about to pull my hair out :cry:

 

I'm using the account_history.php as a template as I want this information to be displayed in exactly the same way, but I can't get past the errors to see if I'm close to accomplishing what I need. Here's the code, please someone tell me what is wrong.

 

 

<?php

$event_history_query_raw = "select o.orders_id, oo.orders_id, op.products_id, s.orders_status_name from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " ot on (o.orders_id = op.orders_id) left join " . TABLE_ORDERS_STATUS . " s on (o.orders_status = s.orders_status_id and s.language_id = '" . $languages_id . "') where o.customers_id = '" . $customer_id . "' order by orders_id DESC";

 

$event_history_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_EVENT_HISTORY, $event_history_query_raw, $event_history_numrows);

$event_history_query = tep_db_query($event_history_query_raw);

 

$info_box_contents = array();

 

if (tep_db_num_rows($event_history_query)) {

while ($event_history = tep_db_fetch_array($event_history_query)) {

$event_history_query = tep_db_query("select count(*) as total from " . TABLE_ORDERS , TABLE_ORDERS_PRODUCTS);

$event_history = tep_db_fetch_array($event_history_query);

 

 

$event_heading = '<table border="0" width="100%" cellspacing="0" cellpadding="2">' . "n" .

' <tr>' . "n" .

' <td class="main"><b>' . TEXT_EVENT_NAME . '</b> ' . $event_history['op.products_name'] . '</td>' . "n" .

' <td class="main" align="right"><b>' . TEXT_ORDER_STATUS . '</b> ' . $event_history['orders_status_name'] . '</td>' . "n" .

' </tr>' . "n" .

'</table>';

 

$event = '<table border="0" width="100%" cellspacing="0" cellpadding="2">' . "n" .

' <tr>' . "n" .

' <td class="main" width="50%" valign="top"><b>' . TEXT_ORDER_DATE . '</b> ' . tep_date_long($event_history['date_purchased']) . '<br><b>' . TEXT_ORDER_SHIPPED_TO . '</b> ' . $event_history['delivery_name'] . '</td>' . "n" .

' <td class="main" width="20%"><a href="' . tep_href_link(FILENAME_EVENTS_MATCHING, 'page=' . $HTTP_GET_VARS['page'] . '&order_id=' . $event_history['orders_id'], 'SSL') . '">' . TEXT_VIEW_ORDER . '</a></td>' . "n" .

' </tr>' . "n" .

'</table>';

 

new tableBox(array(array('text' => $event_heading)), true);

new infoBox(array(array('text' => $event)));

 

 

My Error Code is:

 

You have an error in your SQL syntax near 'on (o.orders_id = op.orders_id) left join orders_status s on (o.orders_status = ' at line 1 select count(*) as total from orders o, orders_products ot on (o.orders_id = op.orders_id) left join orders_status s on (o.orders_status = s.orders_status_id and s.language_id = '1') where o.customers_id = '2'

 

Ruth in AZ :cry:

Posted

Umm ... who is oo.

 

$event_history_query_raw = "select o.orders_id, oo.orders_id, op.products_id, s.orders_status_name from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " ot on (o.orders_id = op.orders_id) left join " . TABLE_ORDERS_STATUS . " s on (o.orders_status = s.orders_status_id and s.language_id = '" . $languages_id . "') where o.customers_id = '" . $customer_id . "' order by orders_id DESC";

Posted

I caught the typos (oo.orders vs. op.orders and ot vs op), just when I hit submit, :oops: but that isn't the problem. I'm just getting tired from retyping it and made that mistake this last time around. I Corrected it , but I just got a little different error.

 

You have an error in your SQL syntax near 'on (o.orders_id = op.orders_id) left join orders_status s on (o.orders_status = ' at line 1 select count(*) as total from orders o, orders_products op on (o.orders_id = op.orders_id) left join orders_status s on (o.orders_status = s.orders_status_id and s.language_id = '1') where o.customers_id = '2'

Archived

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

×
×
  • Create New...