Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8

Thread: Need Help

  1. #1
    New to the CF scene
    Join Date
    Sep 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Need Help

    I have a php file whose code is this...
    PHP Code:
    <? include("file.php"); ?>
        <?=$total1?>
        <?=$total2?>
    This .php file gets ecexuted successfully.

    Now i want this code to be executed in HTML file:
    Code:
    <html>
    <body>
    <?php
    include("file.php");
    print $total1;
    echo $total2;
    ?>
    </body>
    </html>
    But this .html file shows no output

    Can anyone help me on this ?

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Hello, a warm welcome to this forum!
    It's better to ask this question like "How to execute php in html file".
    Anyway, if you are trying on your local machine, you can accomplish this by adding a line to your httpd.conf (in xampp, it's in xamplite/apache/conf folder)
    AddType application/x-httpd-php .htm near to the other lines like this. And then restart your server. (take a backup of your current file before going to modify and it's using notepad is good)

    If you are trying on your server, please have a look at http://php.about.com/od/advancedphp/p/html_php.htm
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New to the CF scene
    Join Date
    Sep 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thankyou abduraooft
    I am doing this on a linux server but i cant see any .htaccess nowhere
    What shall i do now ?

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    If you are trying on your local machine with the default apache in Linux, try to locate your apache-config file named httpd.conf.
    It'll be somewhere
    Code:
        * Red Hat / Fedora Core / CentOS: /etc/httpd/conf/httpd.conf or /etc/httpd/conf.d/application.conf
        * Novell SuSE: /etc/apache2/httpd.conf or /etc/apache2/conf.d/application.conf
        * Ubuntu (dapper 6.06) / Debian: /etc/apache2/apache2.conf or /etc/apache2/conf.d/application.conf
    If you are trying to make it work on your website, then create a file named .htaccess having a single line as specified above and then upload it to your directory where your file is located.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    New to the CF scene
    Join Date
    Sep 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I get the following error now

    Code:
    Warning: include(folder/file.php) [function.include]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /.../user/htdocs/index.htm on line 146
    
    Warning: include() [function.include]: Failed opening 'folder/file.php' for inclusion (include_path='.:/usr/share/pear-php5') in /.../user/htdocs/index.htm on line 146
    
    Notice: Undefined variable: total_uniques in /.../user/htdocs/index.htm on line 147
    Last edited by rashy; 09-04-2007 at 06:53 PM.

  • #6
    New to the CF scene
    Join Date
    Sep 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    abduraooft please can you help me on this Please

  • #7
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Quote Originally Posted by rashy View Post
    I get the following error now
    [code]Warning: include(folder/file.php) [function.include]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /.../user/htdocs/index.htm on line 146
    Is it caused by the above updation? I think this error due the mismatch in address that you've used to refer the file.php and it's actual path with respect to your current file.

    Currently I'm working on windows with xampp, and I did the trick by .htaccess in a website and by httpd.conf in my local server.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #8
    New to the CF scene
    Join Date
    Sep 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    abduraooft i am making all these changes at my server(website) which is running on Linux on the index.html page which is referring to a file.php inside a folder so i use require(folder/file.php) but no luck
    Please help me....

    Update:
    abduraooft now i copied all the contents of folder to the same directory ...
    Now all of the stuff works fine thanks
    Last edited by rashy; 09-06-2007 at 04:39 PM.


  •  

    Posting Permissions

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