Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Mar 2005
    Posts
    561
    Plugin Contributions
    4

    Default Whats wrong with this query? Fresh eyes needed ;)

    Theres only so long you can go staring at the same 2 line query wondering why it doesnt work before it drives you crazy.

    PHP Code:
    $points_query $db->Execute("SELECT customers_shopping_points FROM " TABLE_CUSTOMERS " WHERE customers_id = '" . (int)$id "' AND customers_points_expires > CURDATE() LIMIT 1"); 
    Can anyone with less tired eyes than me suggest a solution as to why this is causing a Call to a member function on a non-object error.

    Thanks muchly.

  2. #2
    Join Date
    Nov 2003
    Posts
    1,987
    Plugin Contributions
    15

    Default Re: Whats wrong with this query? Fresh eyes needed ;)

    I think you are trying to use this line of code inside a function, but forgot to make $db global.

    like:
    PHP Code:
    global $db

  3. #3
    Join Date
    Mar 2005
    Posts
    561
    Plugin Contributions
    4

    Default Re: Whats wrong with this query? Fresh eyes needed ;)

    Thanks for that.
    I now get an 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 'Object' at line 1
    in:
    [Object]

    PHP Code:
    if (zen_not_null(POINTS_AUTO_EXPIRES)){
        global 
    $db;
          
    $points_query $db->Execute("SELECT customers_shopping_points FROM " TABLE_CUSTOMERS " WHERE customers_id = '" . (int)$id "' AND customers_points_expires > CURDATE() LIMIT 1");
        } else {
          
    $points_query $db->Execute("SELECT customers_shopping_points FROM " TABLE_CUSTOMERS " WHERE customers_id = '" . (int)$id "' LIMIT 1");
        }
        
    $points $db->Execute($points_query);

        return 
    $points['customers_shopping_points'];
      } 

  4. #4
    Join Date
    Mar 2004
    Posts
    16,042
    Plugin Contributions
    5

    Default Re: Whats wrong with this query? Fresh eyes needed ;)

    try using the global Outside the if statement
    Zen cart PCI compliant Hosting

  5. #5
    Join Date
    Mar 2005
    Posts
    561
    Plugin Contributions
    4

    Default Re: Whats wrong with this query? Fresh eyes needed ;)

    Hi Merlin,
    I tried that first time around adding it to the top of the file.
    If I do that I get the same fatal error
    Fatal error: Call to a member function on a non-object

    PHP Code:
    if (zen_not_null(POINTS_AUTO_EXPIRES)){
          
    $points_query $db->Execute("SELECT customers_shopping_points FROM " TABLE_CUSTOMERS " WHERE customers_id = '" . (int)$id "' AND customers_points_expires > CURDATE() LIMIT 1");
        } else {
          
    $points_query $db->Execute("SELECT customers_shopping_points FROM " TABLE_CUSTOMERS " WHERE customers_id = '" . (int)$id "' LIMIT 1");
        } 
    Feeling much fresher today but cant figure this out for the life of me

  6. #6
    Join Date
    Mar 2005
    Posts
    561
    Plugin Contributions
    4

    Default Re: Whats wrong with this query? Fresh eyes needed ;)

    ahhhhh the wonders of coca cola ;)
    Ive figured it out, theres not meant to be any _query on any of the queries so...

    if (zen_not_null(POINTS_AUTO_EXPIRES)){
    $points_query = $db->Execute("SELECT customers_shopping_points FROM " . TABLE_CUSTOMERS . " WHERE customers_id = '" . (int)$id . "' AND customers_points_expires > CURDATE() LIMIT 1");
    } else {
    $points_query = $db->Execute("SELECT customers_shopping_points FROM " . TABLE_CUSTOMERS . " WHERE customers_id = '" . (int)$id . "' LIMIT 1");
    }

    Isnt meant to be there.

 

 

Similar Threads

  1. whats wrong with this css for my dropdown menu?
    By 1kell in forum Templates, Stylesheets, Page Layout
    Replies: 9
    Last Post: 28 May 2010, 02:47 AM
  2. Guess whats wrong with this code.... (footer links)
    By customk1 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 30 Mar 2009, 01:40 AM
  3. What's wrong with this query ?
    By emmdee in forum Basic Configuration
    Replies: 5
    Last Post: 10 Jul 2006, 06:21 AM

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