• Help with PHP

    • This topic has 4 replies, 4 voices, and was last updated 10 years ago.
    Author
    Topic
    #500225

    What I want to do is select a month from a dropdown and then have a
    PDF file named SL_mmm.pdf display where mmm is the month passed from
    the dropdown. Both the *.php file and the *.htm files are in the same
    directory with the PDF file in a subdirectory under that.

    What is happening is on the htm page I am picking Feb and hitting Go, then
    the browser shows website/PVETest.php?month=Feb
    but I get page not found 404 error but it is there.
    It is like the htm page is not really getting to the PHP file OR do I have things
    in the wrong place.

    If I try to run the php code directly from the command prompt on the server
    I get a could not open file message

    Thanks for you help in advance

    Environment:

    Software loaded and verified
    Win Server 2003
    IIS 6.0
    PHP 5.4
    VC9 x86
    FastCGI
    WinCache 1.3
    Visual C++ Redistributable files for X86

    PHP has been tested and works from command prompt
    All FastCGI changes have been made per documentation

    TestDropDown.htm code

    Mar
    Feb
    Jan

    PHPTest.php code

    Viewing 2 reply threads
    Author
    Replies
    • #1507578

      I display pdf’s in php doing this:

      header(‘Content-type: application/pdf’);
      header(‘Content-Disposition: attachment; filename=”download.pdf”‘);
      readfile($filename);

      • #1507667

        I display pdf’s in php doing this:

        header(‘Content-type: application/pdf’);
        header(‘Content-Disposition: attachment; filename=”download.pdf”‘);
        readfile($filename);

        THANKS I will use that for another place I need to do that but
        I still want the drop down to pass part of file name.

    • #1507761

      Hi Slovey,
      I see that your original post contains

      TestDropDown.htm code

      but your php script fragment is preceded by “PHPTest.php code”.

      I wasn’t sure if these names were literally those being used in your test environment.

      Dave

    • #1507889

      Think your issue might be down to the way you’re using an array value within the string… I always get confused so am perhaps a little guilty of defensive coding in such instances. When you add your $_PUT value I’d prefer to concatenate it rather than embed it like you do, but if you do embed it you can enclose the value within brackets. Here’s an example:

      [PHP] $arr = array(
      “one” => “one”,
      “two” => “two”,
      “three” => “three”);

      echo “Hello $arr[‘one’]
      “; // Won’t work
      echo “Hello “.$arr[‘two’].”
      “; // Will work – preferred by me in a defensive way
      echo “Hello {$arr[‘three’]}
      “; // Will also work
      [/PHP]
      So one possible solution would be to do this:

      [PHP] $url=’http://www.loventhal.com/Public/SL_’.$_PUT[‘month’].’.pdf’;[/PHP]

      or

      [PHP] $url=’http://www.loventhal.com/Public/SL_{$_PUT[‘month’]}.pdf’;[/PHP]

      It looks as though you were thinking along those lines anyway as you had an period in your code before the month…?

      Other than that I’d remember to tell the browser to expect a PDF as well 😉

      Also, bear in mind that PHP deals with single and double quotes in different ways!

      Hope that helps.

    Viewing 2 reply threads
    Reply To: Help with PHP

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: