Results 1 to 9 of 9

Thread: [RESOLVED] Parse it!

  1. #1

    Thread Starter
    Fanatic Member ididntdoit's Avatar
    Join Date
    Apr 2006
    Location
    :uoıʇɐɔoן
    Posts
    765

    Resolved [RESOLVED] Parse it!

    I have searched long and heard, but I have failed to find a working instructions on how to accomplish the following:

    I have a web server (in my closet ) that is running Windows XP Pro SP2 and Apache 2.2 and PHP 5.2.5.5 (I believe) and I have lots of PHP codes that I'm dying to integrate on my site, but would like to make it like CSS (one PHP page that is linked to). My problem is that I cannot link to the php page from an HTML document. I have tried a few ways and none work. I was told that I need to configure Apache to parse the PHP in the HTML (<?php import("myfile.php"); ?>) and actually run the code in myfile.php instead of just read it and ignore it. How can I achieve this? Any help would be much appreciated!


    EDIT: I also have MySQL 5.0 installed, in case that makes a difference...
    Last edited by ididntdoit; Apr 16th, 2008 at 09:59 PM.
    Visit here to learn to make the VB interface fit you!.
    "I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison
    "The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Parse it!

    How is PHP configured? If CGI, did you add the CGI handler directives? If SAPI, did you add the LoadModule and content type directives?

    There is an installation tutorial for PHP and Apache in the FAQ thread of this forum.

  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Parse it!

    You do need to configure Apache to send the request to the PHP interpreter. Would you like to run PHP as a module (within the Apache process) or as a CGI (a separate process from Apache)?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4

    Thread Starter
    Fanatic Member ididntdoit's Avatar
    Join Date
    Apr 2006
    Location
    :uoıʇɐɔoן
    Posts
    765

    Re: Parse it!

    Hmmm... I'm new to most of this. I'm not sure what CGI or SAPI is or what the difference is. As for VisualAd's comment, I have added it ass a module to apache with:

    Code:
    LoadModule php5_module "c:/php/php5apache2_2.dll"
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php .php .html
    AddType application/x-httpd-php-source .phps
    
    and
    
    PHPIniDir "C:/php"
    I can run a straight PHP file fine, and one web page I have uses

    Code:
    <form enctype="multipart/form-data" action="uploader.php" method="POST">
    
    Choose a file to upload: <input name="uploadedfile" type="file" /><br />
    
    <input type="submit" value="Upload File" />
    </form>
    <a href="uploads">Uploaded stuff</a>
    as an upload code which is in uploader.php and it works fine. Is there some other way to reference a PHP file like this to include it's code? I'll attach the php I'm trying to get working. It's a visual hit counter.
    Attached Files Attached Files
    Visit here to learn to make the VB interface fit you!.
    "I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison
    "The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge

  5. #5
    Fanatic Member
    Join Date
    Oct 2004
    Posts
    751

    Re: Parse it!

    So much for OOP now a days!
    But really, you should just be able to include counter.php where you want it displayed and it should work.
    My Projects: [ Instant Messagener Client/Server ] [ VBPictochat ]

    My Sites:
    [ Datanethost ]
    [ Helpdesk ]

    Remember if my post was helpful then Rate This Post.

  6. #6

    Thread Starter
    Fanatic Member ididntdoit's Avatar
    Join Date
    Apr 2006
    Location
    :uoıʇɐɔoן
    Posts
    765

    Angry Re: Parse it!

    I know. It just refuses to. I have:

    Code:
    <html>
    <font face="Courier New">
    Hello <(^^,)>
    </font>
    </html
    
    <?php
    
    function foo()
    {
        global $color;
    
        include 'vars.php';
    
        echo "A $color $fruit";
    }
    
    /* vars.php is in the scope of foo() so     *
     * $fruit is NOT available outside of this  *
     * scope.  $color is because we declared it *
     * as global.                               */
    
    foo();                    // A green apple
    echo "A $color $fruit";   // A green
    
    ?>
    in index.html, and:

    Code:
    <?php
    
    $color = 'green';
    $fruit = 'apple';
    echo "A $color $fruit"; // A
    include 'vars.php';
    echo "A $color $fruit"; // A green apple
    ?>
    in vars.php. For some reason, Apache REFUSES to allow PHP to be run in an HTML document. Does anyone know why and/or how to fix it? Please?
    Visit here to learn to make the VB interface fit you!.
    "I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison
    "The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge

  7. #7

    Thread Starter
    Fanatic Member ididntdoit's Avatar
    Join Date
    Apr 2006
    Location
    :uoıʇɐɔoן
    Posts
    765

    Re: Parse it!

    WOW! This is really weird.

    Code:
    <html>
    <font face="Courier New">
    Hello <(^^,)>
    </font>
    </html
    
    <?php phpinfo() ?>
    Shows <(^^,)> AND the PHP info screen! BUT,

    Code:
    <html>
    <font face="Courier New">
    Hello <(^^,)>
    </font>
    </html
    
    <?php include'test.php' ?>
    with <?php phpinfo() ?> in test.php doesn't work. Does anyone have any suggestions about this?


    EDIT: nvmd, I named test.php wrong. Now it works. I will have to check around to see why my other code won't work. I will mark this resolved when I get it fixed.
    Last edited by ididntdoit; Apr 19th, 2008 at 08:59 PM.
    Visit here to learn to make the VB interface fit you!.
    "I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison
    "The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge

  8. #8
    Fanatic Member
    Join Date
    Oct 2004
    Posts
    751

    Re: Parse it!

    Lets tackle one problem at a time.
    The reason Apache doesn't automatically parse PHP in an html document because it's not told to. Check your Apache configuration.
    But the better question is why do you want to use PHP coding in an html file, the unofficial standard is that php code should be in .php (or .php5, phps ect) files.
    My Projects: [ Instant Messagener Client/Server ] [ VBPictochat ]

    My Sites:
    [ Datanethost ]
    [ Helpdesk ]

    Remember if my post was helpful then Rate This Post.

  9. #9

    Thread Starter
    Fanatic Member ididntdoit's Avatar
    Join Date
    Apr 2006
    Location
    :uoıʇɐɔoן
    Posts
    765

    Re: Parse it!

    OK, I have no idea why it wasn't working before - not one clue. But, it seems to work now. Yes I did forget to close the html tag properly in my last post, but closing it works fine too. Thanks guys!
    Visit here to learn to make the VB interface fit you!.
    "I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison
    "The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width