1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Newbie question; Need help inserting php in html

Discussion in 'PHP' started by comcenter, Aug 10, 2007.

  1. #1
    I am having a hard time trying to insert a simple image browsing php script in an html page.
    Can somebody point me in the right direction.

    The script works when I link to it directly (/album/index.php)
    but I want this to work within a table in html, so i tried renaming the photo page to photos.shtml and inserting the php script as a server side include, then I get [an error occurred while processing this directive]

    I don't even know if this is possible.

    Any ideas?
     
    comcenter, Aug 10, 2007 IP
  2. Fewleftstanding

    Fewleftstanding Peon

    Messages:
    438
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can't have a php file in a html file, you will need to use a php include or something like that, and rename your html file to a php file. You can't execute php code in a html file.
     
    Fewleftstanding, Aug 10, 2007 IP
    comcenter likes this.
  3. Doskono

    Doskono Peon

    Messages:
    153
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    That said, on a .php file you can also put in html, that will work. But not the other way arround
     
    Doskono, Aug 10, 2007 IP
    comcenter likes this.
  4. sarav_dude

    sarav_dude Peon

    Messages:
    10
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Where is your html file hosted , is that server supports the php itself ?

    Are you using following type of directive in your html ?

    <!--#include file="path.html" -->

     
    sarav_dude, Aug 10, 2007 IP
    comcenter likes this.
  5. Kuldeep1952

    Kuldeep1952 Active Member

    Messages:
    290
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    60
    #5
    You can try 2 different approaches:

    1) Use an IFRAME to insert the PHP script in the html file.

    2) Modify your .htaccess file and add this line

    AddType application/x-httpd-php .html

    If this works on your Server, your html file will be parsed as a php file
    and can include any php command, such as include.

    Hope this helps.

    Kuldeep
     
    Kuldeep1952, Aug 10, 2007 IP
    comcenter likes this.
  6. comcenter

    comcenter Well-Known Member

    Messages:
    706
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    130
    #6
    Thank you everyone for pointing me in the right direction;

    with the information provided it is now up to me to get to work and get this page running;

    I appreciate your support


    ..
     
    comcenter, Aug 11, 2007 IP
  7. adamk1

    adamk1 Active Member

    Messages:
    110
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #7
    you can make your php files to parse in html files by changing the .htaccess as below

    AuthName www.example.com
    AuthUserFile /home/play/public_html/_vti_pvt/service.pwd
    AuthGroupFile /home/play/public_html/_vti_pvt/service.grp
    
    RemoveHandler .html .htm
    AddType application/x-httpd-php .php .htm .html
    HTML:
     
    adamk1, Aug 12, 2007 IP