corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » Anyone know PHP? Bit of help needed...


New Topic

New Poll
  <<  1    2  >> Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author Anyone know PHP? Bit of help needed...
liamC
Member

Registered: 28th Feb 04
User status: Offline
23rd Nov 06 at 20:10   View User's Profile U2U Member Reply With Quote

I have made a header file called header.php

I have made an index.php file and want the top of index.php to show the text/image that is in header.php. I have added this code;

code:
<?php include ($_SERVER['DOCUMENT_ROOT'].'header.php') ?>


I keep getting this error:

quote:

Fatal error: Call to a member function on a non-object in /home/.saggy/username/domain.com/site/header.php on line 51


Anyone know where I'm going wrong?

[Edited on 23-11-2006 by liamC]

[Edited on 23-11-2006 by liamC]
PaulW
Member

Registered: 26th Jan 03
Location: Atherton, Greater Manchester
User status: Offline
23rd Nov 06 at 20:22   View User's Profile U2U Member Reply With Quote

meh you edited

issue is a problem in the header.php file (line 51 as it says), not with the include statement itself

[Edited on 23-11-2006 by PaulW]
liamC
Member

Registered: 28th Feb 04
User status: Offline
23rd Nov 06 at 20:35   View User's Profile U2U Member Reply With Quote

There is no line 51 mate, that's the problem!

Basically I'm just doing a test site to get it working!

In header.php I have a link to www.yahoo.com

In index.php, I have the code above, and a word saying 'test'!

PaulW
Member

Registered: 26th Jan 03
Location: Atherton, Greater Manchester
User status: Offline
23rd Nov 06 at 20:36   View User's Profile U2U Member Reply With Quote

post the code contained in header.php here
Doug
Member

Registered: 8th Oct 03
User status: Offline
23rd Nov 06 at 20:37   View User's Profile U2U Member Reply With Quote

Post the code up from your header.php file.

i bet you have forgotten to put a ; in there somewhere!
liamC
Member

Registered: 28th Feb 04
User status: Offline
23rd Nov 06 at 20:50   View User's Profile U2U Member Reply With Quote

yay! I got it working; my first bit of PHP Code

Basically, I've put a link to yahoo.com in the header.php file, and put the word 'test' in index.php

Here is the code for both pages for future help for anyone.

HEADER.PHP

code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
}
-->
</style></head>
<body>
<a href="www.yahoo.com" target="_blank">www.yahoo.com</a>
</body>
</html>


INDEX.PHP

code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
}
-->
</style></head>

<body>
<?php include ($_SERVER['DOCUMENT_ROOT'].'/header.php') ?>
<br />
test
</body>
</html>


[Edited on 23-11-2006 by liamC]
Steve
Premium Member

Avatar

Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
23rd Nov 06 at 20:53   View Garage View User's Profile U2U Member Reply With Quote

theres no php in the header file lol
liamC
Member

Registered: 28th Feb 04
User status: Offline
23rd Nov 06 at 20:59   View User's Profile U2U Member Reply With Quote

I wasn't bothered about that mate, I just wanted the index.php page displaying whatever was in the header.php file.

New to it, so just having a play around

drax
Member

Registered: 5th Feb 05
Location: Sittingbourne, Kent
User status: Offline
23rd Nov 06 at 21:08   View User's Profile U2U Member Reply With Quote

You're better off including content from pages, INTO a template, rather than calling a template file into a content file
John
Member

Registered: 30th Jun 03
User status: Offline
23rd Nov 06 at 21:10   View User's Profile U2U Member Reply With Quote

Where did you find the best for learning php liam?

Just looking about google?
Steve
Premium Member

Avatar

Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
23rd Nov 06 at 21:28   View Garage View User's Profile U2U Member Reply With Quote

you need to call it as a template, and parse it anything in an include will try and read that file as php and that file isnt php hence why your getting the error

[Edited on 23-11-2006 by Steve]
drax
Member

Registered: 5th Feb 05
Location: Sittingbourne, Kent
User status: Offline
23rd Nov 06 at 21:31   View User's Profile U2U Member Reply With Quote

What are you talking about? I include .php's all the time which dont have PHP in
Steve
Premium Member

Avatar

Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
23rd Nov 06 at 22:00   View Garage View User's Profile U2U Member Reply With Quote

what i mean is, simply by including that file it wont display on your page until you actually output it as an array and parse it

[Edited on 23-11-2006 by Steve]
liamC
Member

Registered: 28th Feb 04
User status: Offline
23rd Nov 06 at 22:05   View User's Profile U2U Member Reply With Quote

John; yes, just be looking about google.

Steve; that piece of coding works fine to display things from the header.php file

I will have a flash animation and a list of links in header.php and it will save putting them all in each file.

There won't be anything wrong with doing that?
Steve
Premium Member

Avatar

Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
23rd Nov 06 at 22:07   View Garage View User's Profile U2U Member Reply With Quote

yes but when you try and include it, unless you tell it to output to the browser it wont do anything or you'l get errors.

Basically when you incldue it it wil read whats in that file, and do nothing until you tell it to.

In this case you want to either output elements from an array, or just output it straight to the browser using parse
Doug
Member

Registered: 8th Oct 03
User status: Offline
23rd Nov 06 at 22:45   View User's Profile U2U Member Reply With Quote

quote:
Originally posted by John
Where did you find the best for learning php liam?

Just looking about google?


www.freewebmasterhelp.com has some good tutorials
Steve
Premium Member

Avatar

Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
23rd Nov 06 at 22:46   View Garage View User's Profile U2U Member Reply With Quote

i always learn from messing about with it myself, i cannt learn anything from reading stuff, iv always been shit at exams for this reason, when my teachers said i should be getting a's i was coming away with b's and c's, but i was actually better than some of the kids coming away with a's

[Edited on 23-11-2006 by Steve]
ed
Member

Registered: 10th Sep 03
User status: Offline
23rd Nov 06 at 23:11   View User's Profile U2U Member Reply With Quote

quote:
Originally posted by John
Where did you find the best for learning php liam?

Just looking about google?
php.net or codewalkers.com...
drax
Member

Registered: 5th Feb 05
Location: Sittingbourne, Kent
User status: Offline
24th Nov 06 at 00:33   View User's Profile U2U Member Reply With Quote

I reverse engineer things
Steve
Premium Member

Avatar

Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
24th Nov 06 at 08:59   View Garage View User's Profile U2U Member Reply With Quote

if you want to twait til later il write what you need to add to your code.
AndyKent
Member

Registered: 3rd Sep 05
User status: Offline
24th Nov 06 at 09:02   View User's Profile U2U Member Reply With Quote

Steve, that code works fine - my website php-includes are written just like that and everything is output fine without any extra function calls???
Steve
Premium Member

Avatar

Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
24th Nov 06 at 09:03   View Garage View User's Profile U2U Member Reply With Quote

i bung the info from the include into a variable then output the page, means you can add elements of the page as an array, IMO that is a better way of doing it as you can adjust things quickly and site wide if you need to

[Edited on 24-11-2006 by Steve]
AndyKent
Member

Registered: 3rd Sep 05
User status: Offline
24th Nov 06 at 09:11   View User's Profile U2U Member Reply With Quote

I have mine set-up with various useful features, page layouts, log-in/out processes etc. in various functions. I include a whole PHP page - user_access.php for example - and then call the functions as needed.

Actually, I see what you mean now....you can't just bung everything at the top and hope it works as that makes it more complicated......I get you now!
Steve
Premium Member

Avatar

Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
24th Nov 06 at 09:15   View Garage View User's Profile U2U Member Reply With Quote

uh huh
liamC
Member

Registered: 28th Feb 04
User status: Offline
24th Nov 06 at 13:42   View User's Profile U2U Member Reply With Quote

The purpose that I would need it for is fine though surely?

If I make a whole website, and put the navigation links on every single page, surely making a header page with all the links on saves me loads of time as I only have to change one page?

  <<  1    2  >>
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
Meshed standard bumper Cursa Help Zone, Modification and ICE Advice 20 1375
17th May 03 at 01:33
by Miner
 
Car power help needed AdiSRI General Chat 1 553
19th May 04 at 22:59
by AdiSRI
 
website that sells GSi kits? L33 LEG General Chat 12 813
5th Apr 05 at 13:05
by FlameRedCorsa
 
Maths Help Needed - Binary (LOOK IN URGENT) RS6 Geek Day 5 616
24th Jul 05 at 22:40
by VegasPhil
 
F.a.o Fear Basscrazy Help Zone, Modification and ICE Advice 24 1623
24th Jan 06 at 22:48
by Basscrazy
 

Corsa Sport » Message Board » Off Day » Geek Day » Anyone know PHP? Bit of help needed... 28 database queries in 0.0170949 seconds