Jump to content

Recommended Posts

Posted

I'm trying to play off all the "includes" information that has been passed on recently! Can I use an include for a .js file in the same manner that has been shown for header and footer html files?

 

thanks,

Tracy

Posted

However, it's probably much better to have a remote .js file and then have the script file accessed in the head of the html document:

 

<script src="/location/of/file.js" defer="defer" type="text/javascript"></script>

 

Defer apparently will tell the browser to defer loading the javascript until the rest of the html loads. So if you want the js to load at the start, leave the defer part out.

 

The line above that gives the location of the external .js file can be brought into your page with PHP include().

 

This is probably the most effective manner of accomplishing this... but not the only way.

Posted

I will give that a try. I did try to include a .js file using the code that you (surefire) had provided in your tutorial examples, but I got an error on the page and my javascript did not load. I have no idea why it would not work...maybe I'll take a look at it again later and see some little something that I couldn't see at 4am this morning!!!

 

Thanks,

Tracy

Posted

If you want to post the code here... we can see it. To call a JavaScript in an html file is pretty simple.

 

Example:

 

In the head of your document define the location of your script:

 

><script language="JavaScript1.2" src="SomeScript.js" type="text/javascript"></script>

 

Then to call a function:

 

><script language="JavaScript1.2" type="text/javascript">someFunction();</script>

 

Make sure that you have a path to the script if necessary.

Posted

OK...I'm sure I'm doing something simple and stupid...but it won't work (she says pulling her hair out!). When my PHP Bible arrives, I'll think I'll begin to worship it. Then I'll have to buy a Javascript book as well!!!

 

Anyway...there was one thing in a previous post that I didn't understand:

The line above that gives the location of the external .js file can be brought into your page with PHP include().

 

I'm thinking that means I need to have both the include line and the script language line. So, I did this with my code:

 

><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Natural Images Photography Home Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="keywords" content="MY KEYWORDS">
<meta name="description" content="MY DESCRIPTION">
<link href="../main.css" rel="stylesheet" type="text/css">

<?php
include $_SERVER['DOCUMENT ROOT']."inc/parent2.js";
?>
<script src="/inc/parent2.js" defer="defer" type="text/javascript"></script>

</head>
BODY BEGINS HERE...

 

The .js file is in the inc folder on the site root, per the tutorial for footer and header includes. My javascript works fine until I try to take it out of the document and make it a file of it's own.

 

Now...a totally unrelated question. When reading through threads in this Board, I've noticed that sometimes a user name listed at the bottom is in red. Does that mean that that person is currently responding to that thread? Just curious.

 

Thanks,

Tracy

Posted

Cool... thanks for posting the code. That makes it easy to help you.

 

By the way... thanks for giving it a try. It's easier to help, teach, etc, when the other person can see the outcome of the code.

 

Okay.

 

Here's the process to make this work well:

 

1- Create a fully functional html/javascript/whatever else page and save it with .htm or .html extension

2- FTP it to your site and verify that it "works" the way you want it to

3- Once you get your page to the point that you are thinking "Now I'd like to create a kind of template out of this page so I don't have to retype header, footer, nav, etc...." you're ready to use php include() function

 

Looking at your code, what you've attempted to do is to include some sort of js file... that's not what we're trying to do here.

 

We need to back up and explain something about js (of which I'm not an expert). There are two ways to work your javascript into your page... writing the code in the <head> section and then using it in your <body> or having an external .js file, linking to it in the <head>, and using it in the <body>.

 

Most will recommend the second method... external .js file.

 

Alright. So all of your javascript code needs to be in a file that ends with .js

 

It looks like you've called it parent.js

 

I'd rewrite your page like this:

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>Natural Images Photography Home Page</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<meta name="keywords" content="MY KEYWORDS">

<meta name="description" content="MY DESCRIPTION">

<link href="../main.css" rel="stylesheet" type="text/css">

 

<script src="/inc/parent2.js" defer="defer" type="text/javascript"></script>

 

</head>

BODY BEGINS HERE...

 

All I did here was take out the php code.

 

Does your code work? I don't know.

 

It will if

1-Your .js file exists and is placed where you have indicated (inc folder)

2- Your js code is well written

3- the rest of your html document is error free.

 

At this point, if your file doesn't work... it's not php... it's js or html problem.

 

You have to have a working html page before going any further... done?

 

Next step is to take all the repetitive stuff out and put it into files we can include. This is as simple as cutting and pasting.

 

Here we go...

 

See next post...

Posted

Copy everything above and including the <body> tag and put it in a file that ends with .php (you could also use .inc put just use .php... it's safer).

 

In this example... we'll call it header.php and the contents will be:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>Natural Images Photography Home Page</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<meta name="keywords" content="MY KEYWORDS">

<meta name="description" content="MY DESCRIPTION">

<link href="../main.css" rel="stylesheet" type="text/css">

 

<script src="/inc/parent2.js" defer="defer" type="text/javascript"></script>

 

</head>

<body>

See how the script line for javascript is written in there just like a regular html document??? Nothing crazy, difficult, or confusing here.

 

Now we need a footer. Let's say you want a copyright at the bottom of every page.

 

Here's footer.php

<table width="100%" border="0" cellspacing="0" cellpadding="0">

  <tr>

    <td><div align="center">Copyright 2003 Natural Images</div></td>

  </tr>

</table>

</body>

</html>

 

See how the footer.php file closes out the tags we opened in the header.php file???

 

So now we have header.php and footer.php... what next?

 

Let's create our first 'real' php page that visitors will see.

 

index.php will look like this:

 

<?php

include $_SERVER['DOCUMENT ROOT']."inc/header.php";

?>

<h1>This is the home page</h1>

<p>This is where the content goes</p>

<?php

include $_SERVER['DOCUMENT ROOT']."inc/footer.php";

?>

 

Notice how everything between the header and footer is html???? It should be... header.php has opening html tags, and footer.php has closing html tags.

 

Load header.php and footer.php to inc folder. Load index.php to your main folder (www.yoursite.com.index.php)

 

Point your browser to www.yoursite.com/index.php and it should work. View the source code and what do you see?

 

HTML... just like you should

 

If you get an error, cut and paste the error in your reply to this post and one of us will help you out.

Posted

Jack,

 

If I use:

 

>include $_SERVER['DOCUMENT ROOT']."inc/footer.php";

What is document root pointing at, and does it work for subdomains going back to the main domain?

 

Cheers

 

Jim

Posted

Thanks, Jack. I do believe I tried it that way...but one can never be sure after trying a million plus times! :D :(

 

I will work on it again tonight after work. I very well may have messed up my javascript code when I made the .js file. Thank you very much...once I get this part made, I will begin the header/footer work!

 

Tracy

Posted

Natimage,

Not to be picky... but what I have described here is extremely different from the code you originally posted.

 

I only say that so you'll read over the details closely... not so that you'll feel bad.

 

You are trying something new and you're going to learn a ton from your efforts.

 

Please read over my two posts very closely. Easy to skip or change the order of steps because of overconfidence.

 

In a nutshell:

Your code used php to incorrectly bring javascript into your html.

 

The rewrite provided removes EVERYTHING from your pages except your content and puts the redundant sections into 2 separate php files that are included.

 

Remember:

Step One:

Create a fully functional html page. If you want js in your page then this has to function correctly too.

 

Step Two:

Cut and paste everything except your content into one of two php files.

 

Step Three:

Your basic php file for the rest of your site pages is:

<?php

include $_SERVER['DOCUMENT ROOT']."header.php";

?>

<p>This is where the content goes</p>

<?php

include $_SERVER['DOCUMENT ROOT']."footer.php";

?>

 

Easy.

Posted
Jack,

 

If I use:

 

>include $_SERVER['DOCUMENT ROOT']."inc/footer.php";

What is document root pointing at, and does it work for subdomains going back to the main domain?

 

Cheers

 

Jim

Jim,

 

The reason I use

$_SERVER['DOCUMENT ROOT'].
is so that the correct url is formed regardless of the position of the webpage in the site directory.

 

Here's what I used to do... before discovering this trick at php.net:

 

I'd write a "template" php file like

<?php

include ("/header.php");

?>

<p>Content</p>

...and so on

 

But the url to my header.php file would be wrong for files located at various points in my site directory. Exampe:

www.mysite.com/path/to/file.php

 

file.php starting off with includes would be referencing the header.php file with a bad relative url.

 

Without even intending to... I came across the $_SERVER['DOCUMENT ROOT']. blurb in a comment from php.net

 

Basically, it's similar to writing your include like an absolute url:

include("http://www.site.com/path/to/header.php");

 

but my understanding is that the server understands it's not an external url.

 

Point is...

 

Looking through my log files, before I found this trick, I noticed that somehow the server was finding the right header.php file but in the meantime I was racking up errors. Not the worst crime in the world... but presented with a solution, I'll take it.

 

So there you have it.

 

There are other great pointers at php.net under 'include()'

 

As to your question on subdomains... I don't know the answer to that one.

 

I do know that you can accomplish the same thing by declaring constants for your subdomain site urls and then using those in your code.

 

I got that idea also from user comments at php.net under 'include()'

 

I'd visit it for more info and to find tricks and solutions that fit your need.

Posted

Jack,

 

I gave up (for now) on bringing the javascript in like I was thinking...I just included all the code in my "header" file.

 

And when I said that I had tried that before...I was ONLY talking about the javascript code line that you had provided. I had not tackled the header/footer project yet. I just didn't know that bringing javascript into a page was quite a bit different than bringing in an .htm file. I was trying to take a baby step and ended up making it more complicated than necessary.

 

I did succeed this evening in creating the "php templates". Now I just have to figure out why my table dimensions were all jacked up!

 

Thanks for all the time you've put into helping me and others here at TCH!!

Tracy

Posted

If you give me the url, I'll take a look. If you have time to post the code too... all the better.

 

But if you don't have time... I understand.

 

 

I was thinking about this thread while driving home and thought that maybe the easiest way to describe this process is taking a working page... splitting it up into three pieces... and reassembling them a split second before they're displayed to your visitor.

 

a)header

b)content

c)footer

 

Just before the page is shown, header written, then content, then footer.

 

So, if the page you start with has issues, then so will your reassembled product. You have to start with a fully functioning web page.

 

Javascript isn't tough, but it can add one more wrinkle to work with.

 

Anyhow, I promise you that when your PHP book arrives, it will suddenly become crystal clear.

Posted

I have a few things I would like to try before I bother anyone with looking through my messy code. It actually may be a couple of weeks as I will be away from my computer all of next week :huh: But if I can't figure it out, I will gladly provide urls and post code!!!

 

Hopefully by then my book will be here and I'll have a few other things finished and out of my hair.

 

Thanks again!

Posted

Can you post your code?

 

I can't imagine why it wouldn't work. Using a subdomain shouldn't have any adverse effect on the location of the included library files.

 

Here's the info I was talking about before.

 

From:

http://us4.php.net/manual/en/function.include.php

 

gmgiles at pacbell dot net

04-May-2003 10:08

 

How to minimize use of absolute filepaths in include() statements across your website, and make your coding life simpler:

 

Using absolute paths to include() files such as custom function libraries is problematic because it relies on a fixed directory structure that must never change - if you reorganize your code or change the name of an include file, you'll have to go back through your code and update every effected include(). That's a huge waste of time and a big hassle. Here's a way to get around that.

 

First, in the root directory of your website, create a file called includes.php. As the name implies, this file will make use of define() to centralize all the absolute filenames that would otherwise be strung throughout your code. The benefit is that if you restructure your code (i.e. rename or move an include file), you only need to edit this one file to make the change propogate site-wide. Here's a simplified example:

 

[includes.php]/*** begin includes.php ***/

// defines

define ("ROOT", "/www/path_to/your_website_dir/"); // filesystem path to root directory

define ("URL_ROOT", "*****/"); // absolute URL to website

 

// my custom function libraries

define("DATABASE_H", ROOT."db_control.php"); // database control functions

define("MESSAGE_H", ROOT."message.php"); // system/error message functions

define("SESSION_H", ROOT."session.php"); // sets session information to be used in other functions

define("SYSTEM_CONFIG_H", ROOT."system_config.php"); // system configuration functions

define("USER_H", ROOT."user.php"); // general user information functions

 

// commonly used page definitions

define ("PAGE_ADMIN", URL_ROOT."admin/admin.php"); // admin page

define ("PAGE_LOGIN", URL_ROOT."login.php"); // login page

define ("PAGE_USER", URL_ROOT."myaccount/manage.php"); // user account home page

define ("PAGE_LOGOUT", URL_ROOT."logout.php"); // logout page

/*** end includes.php ***/

 

In the above code, I use define() to create new constants called ROOT, DATABASE_H, MESSAGE_H, SESSION_H and so on. Those constants are what I will use throughout my website when I need to include() other files - see example.php below. You'll note that some constants are for my custom function libraries, and some are for commonly used pages, such as the login and logout pages (PAGE_LOGIN, PAGE_LOGOUT, etc.). Note that some constants reference files in different subdirectories.

 

Also note that some defines rely on ROOT and others on URL_ROOT; that's because those that rely on ROOT are all custom libraries that the filesystem needs to find, and those that use URL_ROOT are page definitions that rely on a fully qualified domain name that the webserver needs to find.

 

The following example can be located anywhere within your website's directory structure, and because we've defined the paths elsewhere, you no longer have to bother with absolute paths in your code - just use the constants you defined in includes.php:

 

[example.php]

 

/*** begin example.php ***/

<?

// Include includes.php so all our new defines() can be found

include $_SERVER['DOCUMENT_ROOT']."/includes.php"; // include paths

 

// Include the custom library functions we need to use.

// In some instances, using require_once() might be better. YMMV.

include DATABASE_H; // database control functions

include SESSION_H; // session functions

include USER_H;            // general user information functions

 

// go to a specific, commonly used page in the site

header("Location: ". PAGE_USER);

/*** end example.php ***/

 

This method does require that you NEVER rename or move includes.php, but it is very transportable and a big time saver. Hope this helps simplify your coding life a bit! :)

 

?>

Posted

Hi,

 

I have a stinking cold, so my heads not working, its proberley something really easy!

 

><?
define ("ROOT", /home/bugman/www/"); // filesystem path to root directory
define ("URL_ROOT", "http://www.bugmansbrewery.com"); // absolute URL to website
define ("top", URL_ROOT."http://www.bugmansbrewery.com/inc/3Cannons.htm"); // include file
?>
<?
header("Location: ". top);
?>

 

Error is:

 

Parse error: parse error, unexpected '/' in /home/bugman/public_html/hobby/testinc.php on line 2

 

Except there doesn't seem to be

 

What am I missing? (other then a hot drink and my bed?)

 

Jim

Posted

Could it be that

 

define ("ROOT", /home/bugman/www/"); // filesystem path to root directory
should be

 

define ("ROOT", "/home/bugman/www/"); // filesystem path to root directory

 

Note the " before /home, isnt in your code.

Posted

Jim,

 

Maybe I am missing something.

 

You have define ("ROOT", /home/bugman/www/"); // filesystem path to root directory

 

I wrote

 

define ("ROOT", "/home/bugman/www/"); // filesystem path to root directory

 

Could that not be the cause? What you wrote is missing a quotation mark before /home/bugman

Posted

Hi,

 

Ah stupid me, sorry its my head still,its still not solved though:

 

><?

define ("ROOT", "/home/bugman/www/"); 
define ("URL_ROOT", "http://www.bugmansbrewery.com"); 
define ("top", URL_ROOT."/inc/3Cannons.htm");
?>

<?
header("Location: ".top);
?>

 

Gives:

 

Warning: Cannot modify header information - headers already sent by (output started at /home/bugman/public_html/galleries/Jason_Gross/Gallery1/test11.php:8) in /home/bugman/public_html/galleries/Jason_Gross/Gallery1/test11.php on line 9

 

Any reason why?

 

Jim

Posted

Jim,

 

It normally means that in that file, test11.php, either before the <?php or after the ?> at the end of the file, you have whitespace. This causes trouble.

 

It is normally at the bottom of the file (after the "?>") and is caused by using some non-standard text editors to change these files.

 

Put your cursor just after the ?> at the end and see if you use the arrow keys and your cursor moves past the > then you have whitespace. Just put your cursor after the > again and hold the delete key down until all the whitespace is gone. Then save the file and try it again.

Posted
define ("top", URL_ROOT."http://www.bugmansbrewery.com/inc/3Cannons.htm"); // include file

?>

<?

header("Location: ". top);

?>

 

That's a redirect you're doing here. Any visitors accessing this page where you've got the php code listed above are being redirected to 3Cannons.htm

 

I assumed that's what you wanted to do.

 

This is not an include... it's a redirect you're doing.

 

If I've missed the purpose of your code or your intentions, then my apologies.

 

Your //comments leads me to believe that your include file is 3Cannons.htm (although I'd probably encourage you to change it to a php file... not the issue here)

 

If you're trying to include the file, then you need to replace the 'header' function with an 'include' function.

 

I think the 'slow' speed is a result of the redirect... you're sending visitors to a new page as soon as they land on the first one.

 

That's an extra server request, and requires accessing the file and displaying in the browser (you already knew that, of course).

 

If you indeed were trying to do a redirect then there's not enough information posted for me to tell you what's going on.

Posted

Critical mass,

I dig your site, very easy to navigate. I assume you're using OScommerce (think that's what it's called).

 

I also see that you've managed to remove those pesky dynamic urls from your site... nice job. That probably took quite a bit of programming.

 

If you did that yourself then I'd say you know your share of php.

 

On another note...

 

 

The php function header() is very similar to doing a meta refresh/redirect in html. The code on page A tells the server to immediately serve up page B. URL changes completely as you are redirected to page B.

Posted (edited)

Hi,

 

Fixed and working, was supposed to be an include, thanks for that!

 

However, what about graphics? The include means that it looks for the pictures in the folder its been "included" into.

 

E.g. include is in a inc folder on root, but is pulled into a subdomain folder. It looks for the pics in the subdomain folder rather then the original home. How can you get around this?

 

Jim

Edited by Jimuni
Posted
However, what about graphics? The include means that it looks for the pictures in the folder its been "included" into.

 

Do you know this because your images aren't showing up, or because your error logs tell you this is the case, or is everything working okay but you think that this is happening?

 

I ask because I don't seem to have problems with relative urls pointing to img folder/files. But perhaps I haven't inspected my server logs closely enough.

 

So, I'd be interested to know why you ask... maybe something for me to learn here that I've overlooked.

 

However, the answer, I believe, would be your choice of the following:

1- Static url (http://www.yoursite.com/images/pic.jpg)

2- Use $_SERVER['DOCUMENT_ROOT'] . "/path/to/images/pic.jpg"

3- Define 'root' and use ROOT . "path/to/images/pic.jpg"

 

Any three of these should point the server to the exact location of your files in your file directory... regardless of where the php code resides.

 

I dislike the first method... it would seem that the server wouldn't know that this is an internal file, and therefore would take a split second longer... but don't quote me on that.

 

My favoriate choice would be #2... but....

 

Again, I'm not convinced that any of this is necessary.

 

I'd be happy to admit I'm wrong... just hasn't been my experience that these extra steps are necessary.

 

 

 

 

PS - For anyone reading this post who is knew to programming, the whole business of /path/to/whatever is not meant to be literal. If you type this verbatim, it won't work.

 

This is just the best why I know to give instructions to someone with a web directory architecture that is totally unknown to me. You are to replace /path/to/whatever with the actual path directory information that points the server to the location of your file.

Posted

Thanks Jack,

 

I am using OScommerce, cant argue with free. I cant take credit for how it is set up, static URL's and the like. If I had a question I went to their forum and found my answer. I know any issue I had there was a 99% chance somebody else had it as well. I ended up never having to post a question. All I did was follow directions. So all I can take credit for is following those directions correctly. I have much to learn but I think I am slowly getting there.

Posted

Hi,

 

It's doing it cos the pictures are missing, but I admit I have not played with the coding to compensate for the trial movement. I would have thought 2 would be far better!

 

Thanks for all of this :-)

 

Jim

Posted

I don't think all of this is necessary. I rechecked my server logs and it doesn't indicate any problems with included file pointing to images with relative urls.

Posted

Hi everybody!

 

PHP is completely new to me. Just started a few weeks ago.

I wrote a php code that shows links form the database by categories & subcategories. Was working on it for four days, finally got it working :D

 

Now I found out about the include function. I opened a new php page, built a table & put include in every changing part. I put my links into the main cell and now when I click on any category or subcategory - it opens in an blank window and I don't know how to make it to look the same every time I click on other link.

 

I unerstud about including header & footer directly in the php file, but what about sides? I thought that I just can build a table with header, right side cell, main cell and footer and just include my php's in main cell and right cell, but it doesnt stay the same as soon as I click on any links. ;)

 

Mybe its a stupid question, well I'm trying to learn.

 

Thanks :(

Posted

I'm not sure I understand your question, gemini.

 

The only part I could make sense of was:

I unerstud about including header & footer directly in the php file, but what about sides?

 

Regardless of the layout of a page, the html is linear, reads top to bottom just like a recipe. So you can include many different things, header, footer, sides, other php files, other scripts, snippets of code, almost anything.

 

I'd be happy to help you but as Jerry Maguire said "Help me help you." I need to see your php code and a url to the page that's giving you problems.

Posted

Sorry. English is my 3rd languadge - may be this is also a reason ;)

 

http://www.maxgrad.net/default.php

 

the brown part in the middle is changeble. Because my links code is in /links/ directory I couldn't make it working, but typing in whole path with the domain name, you'll see further.

 

------------------------------------------------------------------------------------------

<html>

<head>

<title>MaxGrad.net - Link Exchange Project</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<link href="main.css" rel="stylesheet" type="text/css">

</head>

 

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td background="png/bg.png"><img src="images/logo.gif" width="186" height="115"></td>

</tr>

</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td>

<?

include ("menu.html");

?>

</td>

</tr>

</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td width="150" height="400" bgcolor="#99CCFF">  </td>

<td height="100%" bgcolor="#993300">

<?

if ($id=="") {

include ("http://maxgrad.net/links/links.php");// it doesn't work like /links/links.php either links/links.php

}

else {

include ("$id.php");

}

?>

</td>

</tr>

<tr>

<td colspan="2">

<?

include ("footer.html");

?>

</td>

</tr>

</table>

<p> </p>

</body>

</html>

------------------------------------------------------------------------------------

 

I want header and footer and the right side to stay unchangeble and only brown part to change when you click on any links.

 

Hope you understand no what I mean :)

Thanks

Posted

><?php
include "includedfile.php";
?>

 

Your missing the php after your first "?". Also you might want to make sure your getting the path right where the actual included file is.

Posted

I tried this to include the path: include ("$PHP_SELF?path=/links/links.php");

didn't help. And I also added the <?php

Still when you click on any link it opens in a blank window.

Posted

Gemini,

 

Lots of issues in your code.

 

Here's what you need to do... I will point out some specific problems... but the REAL issue can be solved by demonstration. You need to give me a working html page with NO php in it and I'll show you how to use the include function.

 

In general, the overall method you've chosen for coding doesn't seem to make much sense to me... but maybe I'm missing something. So I think there is a bigger issue involved here than nit picking individual lines of code.

 

Now, to point out some other issues here, let's look at specific problems.

 

<?

include ("menu.html");

?>

I don't know if you can include html files successfully... but whether you can or can't... it's my opinion that you should be including a php file, or .inc... NOT html

 

Second, you should change <? to <?php

 

if ($id=="") {

include ("http://maxgrad.net/links/links.php");// it doesn't work like /links/links.php either links/links.php

}

 

Since I can't see your directory tree or the actual links.php file... I can't say for sure what the issue is here. But according to the error message, the file is in another location.

 

else {

include ("$id.php");

}

Your method of coding here is a security risk that is very vulnerable to hacking and site defacement.

 

I would strongly recommend putting in some security measures... one option would replacing your if statement with a switch statement that has a default option. If you need more help with this, then please see the php manual at php.net and look under include()

 

<?

include ("footer.html");

?>

 

Same comment as I made for menu.htm above.

 

I'll make you a deal... if you can provid me with a vaild html page... no php in it at all... and a short explanation of what you want to happen, then I'll post a thread in the scripting forum outlining the step by step process to make it happen.

 

That way, you get code that works and other members get to see php coding example put together from start to finish.

Posted

No... as long as links.php works... which it appears that it does, then we're good to go.

 

What I need you to do is to create a separate folder that you will keep open for TCH users so they can see how we created your pages. You can call the folder anything you want, but I need to know, so that I can link to the example pages. You also need to post the code that I send to you and put it in your folder for other TCH members to see and learn.

 

The folder doesn't have to be accessible to your other visitors, only TCH members will know where it's located.

 

Deal?

 

If so, I need to know:

1-the name of your folder (call it 'tch' if you want)

2-the links you want for your menu... or html code for the menu... either one

 

Then I'll announce the new thread (discussion) where I'll work on your pages and create a tutorial.

 

I'll wait for your response.

Posted

I made the TCH folder. As for the links I don't have any yet. The only one that I wanted to work is a script at http://maxgrad.net/links/links.php

 

Actually I found the same sample posted by you on May 19th in another thread. So I did exactly as you showed, but if I try to include /links/links.php in the same manner that you showed with header.php & footer.php - it give's me an error message for

<?php

include $_SERVER['DOCUMENT_ROOT']."/links/links.php";

?>

 

but it works with

 

I don't really understand the error.

Posted

Here is the error

Warning: main(config.php) [function.main]: failed to create stream: No such file or directory in /home/maxgrad/public_html/links/links.php on line 2

 

Warning: main() [function.main]: Failed opening 'config.php' for inclusion (include_path='') in /home/maxgrad/public_html/links/links.php on line 2

 

Fatal error: Call to undefined function: tablecount() in /home/maxgrad/public_html/links/links.php on line 4

 

Here is the HTML you were asking for

http://www.maxgrad.net/index_.html

 

I actually made the same as you were describing before at http://maxgrad.net/inc/

Posted

Well, here is

http://maxgrad.net/links/links.php

 

now everything opens in the same window with the same design. I had to include the header.php and the footer.php in the actual script. At the beginning I was including the script (as a main content) into the template and every time i click on any link it would open in a new window without header and footer. Looks like this is the way to do it - every time include header and footer in a script that makes your content.

Posted

When I go to this page...

http://www.maxgrad.net/links/links.php

 

It looks like everything is fine and working.

 

But the error message you pasted was indicating that the config.php file was not found in the location your code told the server to go look.

 

Gemini, I'm a little puzzled about how to help you further. I don't feel like I have a good handle of what you're looking for.

 

Do me a favor... this thread is getting a little long. If you want more help, please start a new thread in the Scripting forum and I'll see what I can do to help.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...