Multiple php scripts inside php program

Gudday all
I am slowly converting my wife’s site to php from html for various reasons. Ability to change many files with changes to another file is the major reason. Plus learning php as I go.

My stumbling block now is getting multiple php scripts to run inside the main php program. I can get two (2) but not a third to run.
The sites pages have a php navigation column which works fine and a footer which works fine too. But when I add a php script to allow the visitor to download an orderform it fails.
The error message is

Fatal error: Call to undefined function phpheader() in /home/petalsan/public_html/downloadorderform.php on line 1

I have created a standalone script called downloadeorderform.php (originality is not a strong point). To try to troubleshoot I added the calling function to a smaller script that I have been using for various tasks called footer.php.

The calling function resides in the html snippet below (living inside the php program) and is the 2nd one viz. the link <a class="navlink" href="downloadorderform.php">available</a>

<p>An <a class="navlink" href="orderform.pdf">order form</a>, suitable for posting or scanning, is <a class="navlink"* href="downloadorderform.php">available</a>.</p>

The downloadorderform.php is shown below
<?php* *header("Content-disposition: attachment; filename=orderform.pdf");* *header("Content-type: application/pdf");* *readfile("orderform.pdf");* *?>

I have tried it as an include i.e.
<?php include 'downloadorderform'; ?>

No doubt the error is staring me in the face but I cannot see it.

Please advise.
Footer.php lives at http://www.petalsandpatches.com/footer.php

EDIT
This post has been reformatted by enclosing the inline code with backticks
`
before and after the code.

Hi there Tigers,

Trying to help you here is sort of like guessing the color of your eyes over a phone call since all the links in your post are broken and we only get to see 4 lines of irrelevant PHP code to solve your problem, but I can tell you that the error is telling you that the function hasn’t been defined. This probably means that downloadorderform.php is using code ffrom a packaged script that expects another file to be included(like functions.php).

If you can find where phpheader is defined(you can do a directory-wide search in most editors), then you can included that file.

Schwim
Sorry for the broken links. Those backticks do have me confused.
Yes the code was from another site. I don’t yet know enough about php to have expected functions/libraries not being defined. (Years of C/C++ at uni and some work should have warned me).

I had the following snippet
<?php header("Content-disposition: attachment; filename=orderform.pdf"); header("Content-type: application/pdf"); readfile("orderform.pdf"); ?>
in downloadorderform.php. I had thought that that was sufficient.
At the risk of exposed gross ignorance what exactly does
“If you can find where phpheader is defined(you can do a directory-wide search in most editors), then you can included that file.” mean?
The directory wide search has me stumped. Do you mean on my host or somewhere/something else?

What I mean by that is you can look for a search term in a directory. For an example, if I’m working on a phpBB site and see a function called “generate_text_for_display($text)” and want to know what it’s doing, I’ll do a directory search for “function generate_text_for_display”. In my editor, the process looks like this:

The search function presents the results at the bottom, allowing me to click on the line number and it will open the script in question. This will allow you to find where the function resides.

If I had to guess, I’d say that you found an upload script on the web, but maybe didn’t include all the content/files it expects.

A little more code from your page and where you got the upload script would be very helpful in figuring out your issue.

Schwim
The location I got the download script from is http://webdesign.about.com/od/php/ht/force_download.htm

The file that calls the download is

<!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>
<title>Footer.php</title>	
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">	
<meta name="description" content="Petals and Patches has exciting original design patterns of Stitcheries, Applique, Quilts for cushions, wall hangings, bags and other enjoyable projects.">	
<meta name="keywords" content="chalkboard fabric, patterns, craft, stitcheries, stitcherys, applique, mail-order, quilts, quilting, applique, bags">	<meta name="robots" content="INDEX">	
<meta http-equiv="PRAGMA" content="NO-CACHE">	
<meta name="AUTHOR" content="Petals &amp; Patches">	
<link rel="stylesheet" type="text/css" href="petalsandpatches-layoutDec13.css">	
<link rel="stylesheet" type="text/css" href="petalsandpatchesApr15.css">
</head>
<body>
<?php
  /*echo "Hello World here I am!";echo "<br>";echo "Today is " . date("Y/m/d") . "<br />";
  echo "Today is " . date("Y.m.d") . "<br />";echo "Today is " . date("Y-m-d") . "<br />";
  echo "Today is " . date("l") . "<br />";echo "&copy;" . date("Y") . "<br />";*/
  echo "<p class='disclaimer'>";
  echo "Every attempt has been made to ensure the accuracy of the information provided on this website. Please advise us if you have any concerns relating to this site. Contact the <a class='navlink' href='mailto:webmaster&#64;petalsandpatches.com?subject=Request for the Webmaster of Petals and Patches'>webmaster</a> for further information". "</p>";
  echo "<p class='webmaster'>";
  echo "Site design © Petals and Patches 2004 - ".date("Y")."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ABN 16 804 843 766". "<br />";
  echo "Site built and maintained by <a class='navlink' href='mailto:webmaster&#64;petalsandpatches.com?subject=Request for the Webmaster of Petals and Patches'>TIGER TIM</a>." . "</p>";
  echo "<p class='disclaimer'>";
  echo "This page last updated on ".date("d F Y ",filemtime("footer.php")) ."</p>";
  echo "-----------------------------------------------------------------------------" . "<br />";
  ?>
  <?php 
  echo "Some of these items may be visible in greater detail. Place or hover your mouse over an item to see if this extra detail is available." . "<br />"; 
  echo "All ïtems can be purchased via our secure shopping cart, or alternatively you can <a class='navlink' href='http://www.petalsandpatches.com/ordering.htm'>mail</a> your order to us." . "<br />";
  echo "We ship your order via surface mail within Australia or airmail outside Australia.". "<br />";
  echo "Our blog will give you a more up to date description of what we are currently doing and our plans for the future.". "<br />";
  echo "You can review the contents of your cart with the Review Cart button near the bottom of navigation column on the left of this page.". "<br />";
  ?> 
  
  <p>An <a class="navlink" href="orderform.pdf">order form</a>, suitable for posting or scanning, is <a class="navlink" href="downloadorderform.php">available</a>. Alternatively a note can be send telling us what item(s) you require including their product code along with the following information</p>
  </body>
  </html>

If you need more info then please conatct me

Hi there Tigers,

Replace all the content in your downloadorderform.php with this:

[code]<?php

header(“Content-disposition: attachment;
filename=orderform.pdf”);
header(“Content-type: application/pdf”);
readfile(“orderform.pdf”);

?>[/code]

Let me know if that works for you.

Sadly Schwim same error message
i.e.
Fatal error: Call to undefined function phpheader() in /home/petalsan/public_html/downloadorderform.php on line 1

Hi there Tigers,

Then we know it’s the format of the file you’re using. In the code I provided you, line 1 contains:

<?php

and nothing more. The fact that the error is stating “phpinclude on line 1” let’s us know that for some reason, the spaces and new lines have been stripped from the code for some reason, leaving you with something that looks like:

<?phpheader("Content-disposition: attachment;

If you can figure out why your code is losing it’s spacing and lines, then you’ll be able to fix your issue.

Schwim
I used notepad to recreate the file and now it seems to work ok.
3 things noted

  1. My HTML editor was removing the CR on line 1.
  2. Works if I convert ‘<?php’ to ‘<?’
  3. The ó in orderform.pdf had an accent on it just like the o shown at the start of this line. Why I have no idea?

I have tested with IE, Chrome & Safari and all work.
Look at enter link description here

It is wrong not to have the php after <? ? I have other scripts where it does not seem to be a problem.

Thank you for your help.