Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Jun 2002
Posts: 670
Code Monkey
Code Monkey
Offline
Joined: Jun 2002
Posts: 670
I've got my site in HTML and have a top, left-hand, and right-hand menu bars. I've added those to my forums (minus the right-hand menu bar). What I want is to be able to make my site PHP, like my forums, and be able to edit the whole site by editing headers and footers (and a header-insert type thing for META tags). This way blank pages for my site will be much shorter and it's easier to find where to put the content on new pages.

So I've already cut up my index page and made separate files for the header.inc.php, header-insert.php, and footer.inc.php, but I don't know how to make my index.php page call the others. Am I making sense. I don't have my PHP book with me here, but I'm sure it's just a tiny little error I'm making. I'll show you the code I'm trying to use on my index.php page:
[]
<?
require("http://www.laondalatina.com/includes/lolheaderinsert.inc.php");
?>
<title>¡Bienvenidos a LaOndaLatina.com! Email, foros de discusión y salas de chat, ¡TODO GRATIS!</title>
<?
require("http://www.laondalatina.com/includes/lolheader.inc.php");
?>

CONTENT OF INDEX PAGE

<?
require("http://www.laondalatina.com/includes/lolfooter.inc.php");
?>
[/]

Unfortunately when I go to http://www.laondalatina.com/index.php I get an error on line 2. I'm not sure what I'm doing wrong (I really know nothing about PHP at all, but I want to know this). Could someone take a look at my code and help me clean this up! I want to convert my site to PHP while it's small and only takes about an hour. Thanks!!!
btw: lol before my header and footer files is just an acronym for my site name.

Sponsored Links
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
You need to use the server path not the URL to your include file.

Hope that helps.

Joined: Jun 2002
Posts: 670
Code Monkey
Code Monkey
Offline
Joined: Jun 2002
Posts: 670
OK. Now what's the server path? Maybe I should add: What is a server path?

Last edited by donJulio; 10/29/2002 8:34 PM.
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
When you log into your website via telnet you can type pwd to see what your path is. Change directories to the location of you rinclude files and use that command to view the server path to your includes.

Something like /home/users/someuser/public_html

or something simular. It will vary.



Also, when you set the $thispath variable in main.inc.php that was a server path or at least it should be. I don't think it works otherwise.

Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
try this path?

/home/laondalatina/www/includes/

Sponsored Links
Joined: Jun 2002
Posts: 670
Code Monkey
Code Monkey
Offline
Joined: Jun 2002
Posts: 670
Thanks to both. I'll try it later tonight. I'll bet my path is:
/home/laondal/www/includes

Joined: Jun 2002
Posts: 670
Code Monkey
Code Monkey
Offline
Joined: Jun 2002
Posts: 670
STILL NOT WORKING I do know that this is the path to my include file:
/home/laondal/www/includes/

This is now the code for my index.php file:
[]
<?
require("/home/laondal/www/includes/lolheaderinsert.inc.php");
?>
<title>¡Bienvenidos a LaOndaLatina.com! Email, foros de discusión y salas de chat, ¡TODO GRATIS!</title>
<?
require("/home/laondal/www/includes/lolheader.inc.php");
?>

CONTENT OF SITE

<?
require("/home/laondal/www/includes/lolfooter.inc.php");
?>
[/]

So what should I do now?

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
I *think* you want "include" instead of require.

Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
It still looks like it can't open the includes because it can't find them. Try placing the include files in the same place as your index page and simply include from there and see if it works. If it works then it's a problem with your path.

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Dave (I'm still learning myself),
but would you use "include" in that instance? Was I right?

What's the difference between 'require' and 'included'?

Sponsored Links
Joined: Jun 2002
Posts: 670
Code Monkey
Code Monkey
Offline
Joined: Jun 2002
Posts: 670
Finally fixed the problem!!! What I did was instead of having /home/laondal/www/includes/lolheader.inc.php, I removed the .php which came after the .inc. Thanks for the help. BTW, Josh, I'm using include now instead of require.

Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
There isn't a big difference between the two.

require will be used no matter where it is in the script so if you use it in a conditional statement such as:

$blah = "0";
if ($blah == "1") {
require "some/file/here";
}

It will be pulled in every time the script is loaded even though the statment is false.



If you use this:

$blah = "0";
if ($blah == "1") {
include "some/file/here";
}

This will not pull the file in because the statment isn't true and it's been included, not required.



Hope that helps.


Oh also, one returns true if it was succesfull. I believe that's the include statment.

$ok = @include "some/file/here";

If the file is included $ok will be set to 1 but if the file failed to be included $ok is set to 0. The @ in front of the include statment is used to suppress the error if any should occur.

$ok = @include "some/file/here";

if ($ok == "1") {

//do this

}
else {

//do this

}





Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
Just curious, did the files you were trying to include have the .php extention? I wouldn't think so if you had to remove that from the include statement to make it work???

Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
Actually, that is not true anymore. Nowadays both of them do exactly the same thing, but handle failure a bit differently. If you use require() the page execution will stop if the file isn't found, if include() is used, the script will continue if the file doesn't exist.

If you want the included file to only be executed once, you will have to use require_once() or include_once().

Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
Looks like it's time for me to get a new book. LoL Thanks Gardener

Joined: Jun 2002
Posts: 670
Code Monkey
Code Monkey
Offline
Joined: Jun 2002
Posts: 670
Actually they did have the .php extension (after the .inc extension), which makes it really weird for me why my new code worked. The only reason I tried that was because I tried putting the URL of the page in my browser and nothing happened (said the page was not found), but when I dropped the .php, the text of the file showed up right there on my screen in Internet Explorer. Strange! But that doesn't mean I still don't want to learn PHP

Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
I still bet its landoalatina? Only way to tell is to ftp or telnet into your server and see the path.

Joined: Jun 2002
Posts: 670
Code Monkey
Code Monkey
Offline
Joined: Jun 2002
Posts: 670
It's laondal. I used Putty and checked. That's my user id also as well as the name of my group.

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Thanks for the info guys.

This young Jedi is still learning.

Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
Well if you used putty it should be pretty easy then. Go to your includes directory via telnet and right down the path that it says. That will be the one you want. I personally find it easier to use an ftp client to do most of my work but have used putty.

Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
He has it working so not sure if he want's to fix it more. It's strange how removing an extention that exists on the file makes it work though. Something isn't right there.

Joined: Jun 2002
Posts: 670
Code Monkey
Code Monkey
Offline
Joined: Jun 2002
Posts: 670
I've started changing my pages and the new code is working so far so good But it is weird. I don't know why having the .inc extension instead of .inc.php makes it work

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
[OffTopic] Sorry, but I can't help but read your posts with that "Eric Cartman" voice from South Park in my head. LOL

We have a user at my site called "Cartman" and he has the Cartman Avatar. I do the same thing with his posts.

LOL Sorry, had to tell you why I was chuckling. LOL [/OffTopic]

Joined: Jun 2002
Posts: 670
Code Monkey
Code Monkey
Offline
Joined: Jun 2002
Posts: 670
I think this graemlin looks a little like my Cartman avatar...

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Attachments
59687-4511.gif (0 Bytes, 30 downloads)

Joined: Aug 2002
Posts: 1,191
Kahuna
Kahuna
Joined: Aug 2002
Posts: 1,191
I'm not fat... I'm just big boned.....



Warm regards

Nikos


Nikos
Joined: Jun 2002
Posts: 670
Code Monkey
Code Monkey
Offline
Joined: Jun 2002
Posts: 670
My Mom is NOT on the cover of Crack Whore magazine god damnitttttt!!!!

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
LOL

And she's never done any German "adult" films????

LOL


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Bill B
Bill B
Issaquah, WA
Posts: 87
Joined: December 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20240506)