Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2012
    Posts
    52
    Plugin Contributions
    0

    help question my function in folder extra_functions doesn't work

    to display some records from sql table, i created my function file named aaa_function.php
    if i put it to module folder, it works,

    but i need this function for many pages, so i put it to the folder /includes/functions/extra_functions/
    but it doesn't work

    any help?

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: my function in folder extra_functions doesn't work

    The Extra directory is auto loading ...

    Where are you using it from, Catalog or Admin?

    How are you using it?
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  3. #3
    Join Date
    Oct 2012
    Posts
    52
    Plugin Contributions
    0

    Default Re: my function in folder extra_functions doesn't work

    i created a very simple code, such as

    $sql = "select * from " . zen_table_name. " where products_id='" . (int)$_GET['products_id'] . "' ";
    $my_query = $db->Execute($sql);
    $my_display = $my_query->fields['column_x'];
    ...

    i want $my_display to display on many pages, such as main page, product info page, product listing page, in attributes ...

    i put it to modules/attributes.php, it displays on product info page
    but i'd like to put it to extra function folder, then i can use it on other page too?
    Last edited by tips007; 22 Jan 2013 at 06:56 PM.

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: my function in folder extra_functions doesn't work

    Did you write that file as:
    Code:
    <?php
    function blah_blah {
    // stuff here
    }
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  5. #5
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: my function in folder extra_functions doesn't work

    Like Ajeh said, if it's a function, you need to write it as a function by wrapping the word "function" around it along with a function name, and passed parameters, and opening+closing braces etc.

    PHP manual for functions: http://www.php.net/manual/en/functions.user-defined.php
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  6. #6
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: my function in folder extra_functions doesn't work

    surely where products_id='" . (int)$_GET['products_id'] will only work on a product page ?
    Phil Rogers
    A problem shared is a problem solved.

  7. #7
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: my function in folder extra_functions doesn't work

    (int)$_GET['products'] is not immediately available to your function ...

    You need to write your function to accept the products_id ...

    Code:
    function my_function($product_id) {
    // blah blah do something here
    }
    then use it as something, if there is a return value, as:
    Code:
    $something = my_function((int)$_GET['products_id']);
    Or, if it is just to perform a task as:
    Code:
    my_function((int)$_GET['products_id']);
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

 

 

Similar Threads

  1. v151 Why doesn't the Search function work on my store?
    By rubyyin in forum General Questions
    Replies: 20
    Last Post: 9 Apr 2014, 10:14 PM
  2. Admin doesn't work using sub folder
    By phishyman2 in forum Installing on a Linux/Unix Server
    Replies: 6
    Last Post: 10 Oct 2011, 07:42 PM
  3. The 'Copy to' function doesn't work any more
    By mybiz9999 in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 20 Sep 2010, 12:34 PM
  4. Search Function Doesn't Work
    By squid in forum General Questions
    Replies: 0
    Last Post: 20 Jun 2007, 02:53 AM
  5. Securing Image folder doesn't work right...
    By Karina_L in forum General Questions
    Replies: 2
    Last Post: 9 Oct 2006, 10:16 PM

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