LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-27-2006, 05:29 PM   #1
nathacof
Member
 
Registered: Aug 2004
Location: Bear, DE, USA
Distribution: Slackware 11, CentOS 5.2, Ubuntu
Posts: 124

Rep: Reputation: 17
php issues


If you visit analext.com you will see what should be my site.

index.php
Code:
<!DOCTYPE>
<html>
<head>
<?php include "/functions.php"; ?>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>Analext - Home</title>
</head>
<body>
<?php header("Analext - Home"); ?>
<center>This is some content <br /> asjdlasjbfnasbflasdbflasjndf</center>
<?php footer(); ?>
<br />
</body>
</html>
functions.php
Code:
<?php
function footer(){ ?>
  <span id="footer"> 2006 - Nathan Coffield </span>
<?php }

function header($heading){ ?>
  <span id="header"><?php echo $heading ?></span>
<?php }?>
If you view the source you'll see that the source has been cut short. Also my functions seem to do nothing. I changed my php.ini file to display errors but there are none on the page. I can't seem to figure this out. Anyone have any suggestions?
 
Old 10-27-2006, 05:59 PM   #2
pnellesen
Member
 
Registered: Oct 2004
Location: Missouri, USA
Distribution: Slackware 12.2, Xubuntu 9.10
Posts: 371

Rep: Reputation: 31
I'm not 100% sure, but I THINK you may want
Code:
echo "<span id=\"footer\"> 2006 - Nathan Coffield </span>";
in your first function, and maybe
Code:
echo "<span id=\"header\">$heading</span>";
in your second.

Or perhaps this might be a little clearer:
Code:
<?php

function footer(){
  echo "<span id=\"footer\"> 2006 - Nathan Coffield </span>;"
}

function header($heading){
  echo "<span id=\"header\">$heading</span>";
}

?>

Last edited by pnellesen; 10-27-2006 at 06:06 PM.
 
Old 10-27-2006, 06:45 PM   #3
nathacof
Member
 
Registered: Aug 2004
Location: Bear, DE, USA
Distribution: Slackware 11, CentOS 5.2, Ubuntu
Posts: 124

Original Poster
Rep: Reputation: 17
Checking out my log there seems to be a problem on line 4 where I'm trying to include functions.php, it says:
Code:
[Fri Oct 27 12:55:21 2006] [error] [client 209.41.163.23] PHP Warning:  main(): Unable to access /functions.php in /vservers/analextc/htdocs/index.php on line 4
[Fri Oct 27 12:55:21 2006] [error] [client 209.41.163.23] PHP Warning:  main(/functions.php): failed to open stream: No such file or directory in /vservers/analextc/htdocs/index.php on line 4
In regards to the code you posted I had it that way previously, I had changed it because some article I read on php.net. I've since changed it back.

Code:
<html>
<head>
<?php include 'functions.php'; ?>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>Analext - Home</title>
</head>
<body>
<?php $title="Analext - Home"; header($title); ?>
<center><p>This is some content <br /> asjdlasjbfnasbflasdbflasjndf</p></center>
<?php footer(); ?>
</body>
</html>
Code:
<?php
function footer(){
echo "<span id=\"footer\"> 2006 - Nathan Coffield </span>"
};

function header($heading){
echo "<span id=\"header\">$heading</span>"
};
?>
^As it is now.

Last edited by nathacof; 10-27-2006 at 06:50 PM.
 
Old 10-29-2006, 11:10 PM   #4
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Maybe you want to change your include statement...

Code:
<?php include "functions.php"; ?>
remove the slash, I doubt that the file is in the root, and if it is I doubt that you want it there...
 
Old 10-31-2006, 06:47 AM   #5
senyahnoj
Member
 
Registered: Jul 2004
Location: Gloucestershire, UK
Distribution: Ubuntu, Debian & Gentoo
Posts: 74

Rep: Reputation: 16
include() requires an absolute rather than a virtual path so if functions.php is in the document_root directory of your webserver:

PHP Code:
<!DOCTYPE>
<html>
<head>
<?php include $_SERVER["DOCUMENT_ROOT"] . "/functions.php"?>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>Analext - Home</title>
</head>
<body>
<?php header("Analext - Home"); ?>
<center>This is some content <br /> asjdlasjbfnasbflasdbflasjndf</center>
<?php footer(); ?>
<br />
</body>
</html>
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP-GD Issues rsvirani Programming 6 08-17-2006 05:59 PM
php issues rrlevron Linux - Newbie 1 02-17-2006 12:24 PM
PHP compiling issues turbo_acura Linux - General 6 10-15-2004 11:17 AM
php issues sheryco Linux - Software 4 03-30-2003 06:12 PM
PHP 4.2 and Apache Issues Peejay Linux - Software 2 06-17-2002 11:22 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration