Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 39
  1. #11
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Can't include catalog functions in seperate PHP file.

    Sounds like a puzzling folder structure.
    .

    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.

  2. #12
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,761
    Plugin Contributions
    9

    Default Re: Can't include catalog functions in seperate PHP file.

    If you have your ZenCart in a folder - - say "shop"

    Try this and adjust for the folder name where you do have ZenCart installed

    Code:
    require('shop/includes/application_top.php');
    Zen-Venom Get Bitten

  3. #13
    Join Date
    Oct 2009
    Posts
    93
    Plugin Contributions
    0

    Default Re: Can't include catalog functions in seperate PHP file.

    Zen cart is installed at root and my new folder is also placed at the root.
    I'm also confused why this error comes if i remove '../' before the folder path.
    I'm trying to fix this error.

  4. #14
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Can't include catalog functions in seperate PHP file.

    Okay, if your script is stuffed into another folder, then yes you'll need to use the "../" to get it to load.

    As for why your json script breaks, that's impossible to know without having a complete copy of your script and knowing what exactly it's trying to do.
    Maybe you should turn on PHP error reporting and see what errors are being encountered by your script?
    .

    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.

  5. #15
    Join Date
    Oct 2009
    Posts
    93
    Plugin Contributions
    0

    Default Re: Can't include catalog functions in seperate PHP file.

    Can you tell me how can I turn on PHP error reporting?

  6. #16
    Join Date
    Oct 2009
    Posts
    93
    Plugin Contributions
    0

    Default Re: Can't include catalog functions in seperate PHP file.

    Dr. Byte, i want to store new data into the database using $db->Execute function.

    Is there any specific file i can include at the top to access this function?

  7. #17
    Join Date
    Oct 2009
    Posts
    93
    Plugin Contributions
    0

    Default Re: Can't include catalog functions in seperate PHP file.

    PHP Code:

    Code:
    require('../admin/includes/functions/database.php');
    
    if ($_POST['submit_personal']) {
    	/* First Name validations Start */
    	if (empty($_POST['firstname'])) {
    		$message['status'] = false;
    		$message['position'] = 'firstname';
    	    $message['message'] = ' Enter first name...';	
    	    echo json_encode($message);
    	}
    	else if (!preg_match("#^[-A-Za-z' ]*$#",$_POST['firstname'])) {
    	  	$message['status'] = false;
    		$message['position'] = 'firstname';
    	   	$message['message'] = ' Not a valid first name...';
    	   	echo json_encode($message);
    	}
    	/* First Name validations End */
    
    	else {
    	
    		$query = "INSERT INTO my_table (expert_id, 
    												 expert_firstname
    												 ) 
    	
    		VALUES ('NULL', 
    												 '".zen_db_prepare_input($_POST['firstname'])."'						 )" ;
    			
    	
    		mysql_query($query);
    		$_SESSION['expert_id'] = zen_db_insert_id();
    		$message['status'] = true;
    		$message['message'] = 'Your personal data is successfully added';
    		echo json_encode($message);
    	}
    }
    This code works fine but if i include require('../includes/application_top.php'); at the top the script stops working.

  8. #18
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Can't include catalog functions in seperate PHP file.

    You can't re-load that database.php file if you've already loaded application_top. You'll need to remove that line.
    And, if this is all intended to be admin-side, then you should be loading the *admin* application_top, not the storefront one.
    .

    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.

  9. #19
    Join Date
    Oct 2009
    Posts
    93
    Plugin Contributions
    0

    Default Re: Can't include catalog functions in seperate PHP file.

    Dr. Byte i have found one problem when i include
    require('../includes/application_top.php');

    That AJAX stops working, whatever i send to JS file using echo command nothing appears on JS file.

    I'm using JQUERY as shown:

    success: function(response, status){
    alert(response.length);
    }

    The length received is 0 but if i remove the application_top.php file i receive 167 bytes in response variable from PHP script.

    Do you think there is any problem with application_top.php which hinders AJAX Call back?

    P.S: I'm working on Store end not Admin end.

  10. #20
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Can't include catalog functions in seperate PHP file.

    Using application top is appropriate and much safer than trying to include functions independently of their context.

    However, to do so your admin ajax handler would need to be in your admin's root folder. From your path names, it looks as though you have it in a folder sitting alongside the place it needs to be.
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

 

 
Page 2 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. separate php file inside catalog can't connect to database
    By caborela in forum General Questions
    Replies: 1
    Last Post: 3 Mar 2012, 09:11 AM
  2. 'include' php file
    By vandiermen in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 6 Sep 2011, 05:41 PM
  3. Include a custom php file in mainpage.php
    By BeautyHealth.com.cy in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 8 Nov 2010, 02:45 PM
  4. How can I include a php file in the header section?
    By Andy_R in forum General Questions
    Replies: 3
    Last Post: 11 Sep 2009, 05:50 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