CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 [SOLVED]How to require_once an external php file?

Print topic Send  topic

Author Message
jsherk

Posts: 34
Posted: 01/24/2009, 12:41 PM

I am having problems trying to include (require_once) a php file into my ccs project. The file is a config file for Moodle (moodle.org), which has all the setup info for that programs db and functions. There are hundreds of inter-connected functions in multipe libraries, so I can't just copy the needed functions into my project.

Normally I would just add require_once('../config.php'); at the top of my new page, but I'm not sure if I can do this in ccs... when I click on the Code tab, the ccs generated code is highlighted in light grey, so I don't know if I am allowed to manually stick some code in with the other include statements.

I have tried sticking it several different places, but I get different errors depending where it goes, so let's start by telling me where I should put it, then I'll post the specific error I get (if any)!!

There seems to be an issue with globally defined variables in the included file... even though they are defined as 'global' in the included file, they do not appear to be available as global in ccs.

Thanks
View profile  Send private message
damian

Posts: 838
Posted: 01/24/2009, 2:46 PM

you need to add a label to your page and set its value in the pages before show event....

LABEL -> BeforeShow -> Custom Code

$output = implode("", file("http://fqdn/config.php"));
$Component->SetValue($output);

SET CONTENT to HTML if the include file displays content.....

or something similar for your circumstance... please note the full path to the file must be provided - NOT relative....

_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
feha


Posts: 712
Posted: 01/24/2009, 4:50 PM

you can add it in _events.php (at the top) per page ...

or at the end of Common.php

_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message
damian

Posts: 838
Posted: 01/24/2009, 6:19 PM

yeah.... i was just thinking about the post and that the file contains functions etc - i woudl probably just include it as feha has suggested - if it contains output do it via the label.
_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
mentecky

Posts: 321
Posted: 01/24/2009, 7:57 PM

You can add any incudes and requires in the white space after:
//End Include Files
in Common.php. CCS will not regenerate over the white space in the common files.

Rick
_________________
http://www.ccselite.com
View profile  Send private message
jsherk

Posts: 34
Posted: 01/25/2009, 6:14 AM

I put the require_once in common.php after "//End Include FIles" and it works perfect now. No more errors and all functions are now accessible.

Thanks everybody.
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.