Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2010
    Location
    Finland
    Posts
    463
    Plugin Contributions
    0

    Default Syntax error in sql-statement (in php), that however executes when executed in sql

    Parse error: syntax error, unexpected 'orders' (T_STRING) in payments.php on line 70
    =====================================================

    Code:
    <?php
    require_once('../includes/tge.php');
    require_once('transfer.php');
    require('includes/application_top.php');
    require(DIR_WS_CLASSES . 'currencies.php');
    $currencies = new currencies();
    
    $action = (isset($_GET['action']) ? $_GET['action'] : '');
    
    if(zen_not_null($action)) {
    switch($action) {
    case 'setflag':
    break;
    } /* switch($action) */
    } /* if(zen_not... */
    ?>
    <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html <?php echo HTML_PARAMS; ?>>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
    <title><?php echo TITLE; ?></title>
    <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
    <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
    <script language="javascript" src="includes/menu.js"></script>
    <script language="javascript" src="includes/general.js"></script>
    <script type="text/javascript">
    <!--
    function init()
    {
    cssjsmenu('navbar');
    if (document.getElementById)
    {
    var kill = document.getElementById('hoverJS');
    kill.disabled = true;
    }
    }
    // ?
    </script>
    </head>
    <body onload="init()">
    <!-- header //-->
    <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
    <!-- header_eof //-->
    
    <!-- body //-->
    <div id='member_hierarcy'>
    <?php##
    global $db;
    global $filehandl;
    global $filehandle;
    global $validation_time;
    global $distribution_time;
    
    $validation_time = date('Y-m-d H:i:s', mktime(23, 59, 59, date('n') - 1, 0, date('Y')));
    $distribution_time = date('Y-m-d H:i:s');
    
    /**************************************************************/
        $query = ”SELECT * FROM orders WHERE orders_status = 3 
                                         AND (prod_profit_distributed IS NULL OR 
                                              prod_profit_distributed = '0000-00-00 00:00:00')
                                         AND (reg_profit_distributed IS NULL OR 
                                              reg_profit_distributed = '0000-00-00 00:00:00')”;
    /***************************************************************/
    $result = $db->Execute($query); // or die(" Err19");
    
    while(!$result->EOF){
    $time = $result->fields['date_purchased'];
    $oid = $result->fields['orders_id'];
    $cid = $result->fields['customers_id'];
    $cft = $result->fields['order_total'];
    $trans1 = ”INSERT INTO transactions (transactions_time,
    transactions_orders_id,
    transactions_customers_id,
    transactions_type,##
    transactions_amount,
    transactions_handle_time,
    transactions_valid)
    VALUES ('”.$time.”', '”.$oid.”', '”.$cid.”', '20', '”.$ctt.”', now(), '1')”;
    $trans2 = $db->Execute($trans1); // or die(" Err20");
    $query_s = "SELECT * FROM customers WHERE customers_nick =##
    (SELECT customers_referral FROM customers##
    WHERE customers_id = '" . $cid . "')";
    $query_sponsor = $db->Execute($query_s); // or die(" Err2");
    $padre = $query_sponsor->fields['customers_id'];
    $trans3 = ”INSERT INTO transactions (transactions_time
    transactions_orders_id,
    transactions_customers_id,
    transactions_type,##
    transactions_amount,
    transactions_handle_time,
    transactions_valid)
    VALUES ('”.$time.”', '”.$oid.”', '”.$padre.”', '21', '”.$ctt/5.”', now(), '1')”;
    $trans4 = $db->Execute($trans3); // or die(" Err21");
    $result->MoveNext();
    } //while(!$result->EOF)
    
    $query2 = ”SELECT * FROM customers WHERE customers_shares > 0”;
    $result2 = $db->Execute($query2); // or die(" Err22");
    while(!$result2->EOF){
    $order = $result2->fields['customers_share_order'];
    $cid = $result2->fields['customers_id'];
    $cft = $result2->fields['customers_shares'];
    $query_multiple = "SELECT * FROM transactions##
    WHERE transactions_orders_id = ”.$order.”
    AND transactions_amount = ”.$cft;
    $query_double = $db->Execute($query_multiple); // or die(" Err2");
    if(!$query_double->recordCount()) {
    $trans5 = ”INSERT INTO transactions SET transactions_time = '2019-04-01 00:00:00',
    transactions_orders_id = ”.$order.”,
    transactions_customers_id = ”.$cid.”,
    transactions_type = 25,
    transactions_amount = ”.$cft.”,
    transactions_handle_time = now(),
    transactions_valid = 1”;
    $trans6 = $db->Execute($trans5); // or die(" Err23");
    } //if(!$query_double->recordCount())
    $result2->MoveNext();
    } //while(!$result2->EOF)
    
    ?>
    </div>
    <!-- body_eof //-->
    <!-- footer //-->
    <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
    <!-- footer_eof //-->
    </body>
    </html>
    <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

  2. #2
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,846
    Plugin Contributions
    25

    Default Re: Syntax error in sql-statement (in php), that however executes when executed in sq

    Check the double quotes in your queries, they are not the standard double quotes right now, but some other quote.

  3. #3
    Join Date
    Mar 2010
    Location
    Finland
    Posts
    463
    Plugin Contributions
    0

    Default Re: Syntax error in sql-statement (in php), that however executes when executed in sq

    That was it - thanks.

  4. #4
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Syntax error in sql-statement (in php), that however executes when executed in sq

    Also, for information, that query is not written to account for the possibility of a database having/using a DB_PREFIX. Instead of hardcoding orders into the query. Should split the query to incorporate the constant TABLE_ORDERS as the table name.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. Replies: 1
    Last Post: 25 Aug 2011, 05:58 AM
  2. Page Not Found Error When Uploading SQL Statement
    By DVDTitan in forum General Questions
    Replies: 1
    Last Post: 28 Mar 2011, 10:11 PM
  3. SQL Syntax Error when updating Account Information
    By charagg in forum Bug Reports
    Replies: 1
    Last Post: 25 Dec 2009, 03:16 AM
  4. SQL syntax error message when emailing
    By sam1001 in forum General Questions
    Replies: 2
    Last Post: 17 Apr 2007, 03:58 PM
  5. sql executed screen error
    By etoile03 in forum Basic Configuration
    Replies: 1
    Last Post: 17 Aug 2006, 07:22 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR