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.
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.
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.