Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 3rd, 2004, 10:15 AM
Authorized User
Join Date: Jul 2004
Location: , , .
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default pass variable into function and retaining value

I have a function that displays the footer on the web pages that uses an image reference. To reference the location of the directory I have created a variable called $image_path that holds the directory location of the images. My code looks like this:


function footer()
   global $image_path;
   echo "<img src=\"$image_path/footer.gif\" alt=\"#\" name=\"footerImage\" width=\"11\" height=\"14\" border=\"0\" id=\"footerImage\">";
I several different footers for different sections of the website.
When I come to call the function it displays it without any problem, but I get the error message:

Fatal error: Cannot redeclare footer() (previously declared in C:\Progra~1\Apache Group\Apache2\htdocs\testsite\includes\common\inc_ common.php:11) in C:\Progra~1\Apache Group\Apache2\htdocs\testsite\includes\common\inc_ common.php on line 9

I have had a look through the PHP books and it looks like that I am doing the right thing in calling the variable and declaring it as global within the function.

Am I doing it wrong?


Reply With Quote
  #2 (permalink)  
Old August 3rd, 2004, 10:36 AM
Authorized User
Join Date: Jul 2004
Location: , , .
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts

problem solved!!!

I was recalling the include file again at the bottom of the web page thats why it was saying there was a redeclare.

silly me!
Reply With Quote
  #3 (permalink)  
Old August 4th, 2004, 06:37 AM
Friend of Wrox
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts

As a matter of interest, why are you using the full URL ("")?

If / is the root directory of your site, and testsite is a subdirectory of it (which is what appears to be happening) then you could point to the images subdirctory via:
<img src="/testsite/images/imagename.png" width... height... etc. />

The leading slash indicates "root of website".

Reply With Quote
  #4 (permalink)  
Old August 4th, 2004, 06:47 AM
Authorized User
Join Date: Jul 2004
Location: , , .
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts

Hi Daniel,

I dont think that I have configured my Apache correctly to do that.

When I put in the / (slash) it goes to the Apache root and I get my perosonal page that I set up.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
send variable in function to another function schoolBoy Javascript How-To 6 March 3rd, 2007 09:16 AM
Pass Value to XSLT variable bonekrusher XSLT 3 October 9th, 2006 10:16 AM
pass java variable to xsl variable kathy1016cats XSLT 1 June 14th, 2006 06:23 PM
pass variable kapi.goel C# 1 January 6th, 2006 05:54 AM
pass form elements variable vickyj Classic ASP Basics 0 October 29th, 2005 04:58 AM

All times are GMT -4. The time now is 10:45 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.