[PHP] to include php file into html page

2001-08-14 Thread Jack

Hi people
I have tried to include php file into html page using the syntax below and it said 
syntax error at this part when the page is loaded. What is wrong with calling php file 
this way? Or is there any other way to call php file from html page?

***
html
body
script language='JavaScript' src='/include/adjs.php/script
/body
/html
***

Jack
[EMAIL PROTECTED]
Love your enemies, it will drive them nuts



Re: [PHP] to include php file into html page

2001-08-14 Thread Evan Nemerson

The language is php, not javascript. Plus I'm not sure if you can use an src 
attribute, but you can use the include or require functions...

http://php.net/manual/en/language.basic-syntax.php





On Tuesday 14 August 2001 14:32, you wrote:
 Hi people
 I have tried to include php file into html page using the syntax below and
 it said syntax error at this part when the page is loaded. What is wrong
 with calling php file this way? Or is there any other way to call php file
 from html page?

 ***
 html
 body
 script language='JavaScript' src='/include/adjs.php/script
 /body
 /html
 ***

 Jack
 [EMAIL PROTECTED]
 Love your enemies, it will drive them nuts

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] to include php file into html page

2001-08-14 Thread Alnisa Allgood

At 4:32 PM -0500 8/14/01, Jack wrote:
Hi people
I have tried to include php file into html page using the syntax 
below and it said syntax error at this part when the page is loaded. 
What is wrong with calling php file this way? Or is there any other 
way to call php file from html page?

***
html
body
script language='JavaScript' src='/include/adjs.php/script
/body
/html
***

Well first of a PHP script is not a JavaScript. You need to actually 
use a php statement to include a php, text, or other file type. There 
are two methods for including a file, the general include, or the 
more stringent, require file.  I've included a sample if both 
statements below:


html
?php
require(/web/ftp/biz/path_to_file/html/includes/globals.php3);
include(/web/ftp/biz/path_to_file/html/includes/location.php3);
?
?php
require($gBasePath . /includes/header.php);
include($gBaseURL . /includes/header.php);
?
?php
require(/includes/header.php);
include(/includes/header.php);
?
..

You'll note some differences:

The first require statement basically indicates the page  shouldn't 
run or display unless this file is found. The path_to_file is given 
implicitly from the server root rather than from the .html folder. 
You can require a file for many reasons, but in general I do so only 
if the information absolutely needs to be included on the page.  So 
for template pages: header, footer, and startBody, closeBody 
statements are all required, as well as a global file and a config 
file, just in case, we rapidly ad a MySQL statement.

The second statement is an include statement, which can use absolute 
or relative path.

The following two statements use the same method, but call on 
specifications defined in the globals file. The global file defines 
a BaseURL (http://www.yourdomain.net), and a BasePath 
(/web/path_to_file).  Once defined they can be used to specify a full 
path in more relative terms. This is useful for files that are called 
throughout the site, since if your always using a header, on ever 
page, regardless of directory, you don't want to code for it 
../includes/header.php on one page and ../../../includes/header.php 
on the next. A global base or global url, will keep the code 
portable, short, and sweet.

The last two statements basically specify relative paths, for 
including files within the same folder.

Alnisa

-- 
   .
Alnisa  Allgood
Executive Director
Nonprofit Tech
(ph) 415.337.7412  (fx) 415.337.7927
(url)  http://www.nonprofit-techworld.org
(url)  http://www.nonprofit-tech.org
(url)  http://www.tech-library.org
   .
Nonprofit Tech E-Update
mailto:[EMAIL PROTECTED]
   .
applying technology to transform
   .

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]