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.

PhP script into web page

Discussion in 'PHP' started by scopeweb, Dec 28, 2005.

  1. #1
    Hi,

    I want to run a PHP script in an already prepared web page. Can anyone help?

    Thanks
    :rolleyes:
    SEMrush
     
    scopeweb, Dec 28, 2005 IP
    SEMrush
  2. n0other

    n0other Peon

    Messages:
    146
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I assume the page is static and you have no knowledge of PHP. Just insert

    
    <?php include('path/to/your/script.php'); ?>
    
    Code (markup):
    Somewhere in HTML template, where you want the scripts output located.
     
    n0other, Dec 28, 2005 IP
  3. scopeweb

    scopeweb Guest

    Messages:
    494
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks n0other, I will give that a try!
     
    scopeweb, Dec 28, 2005 IP
  4. mdvaldosta

    mdvaldosta Peon

    Messages:
    4,079
    Likes Received:
    362
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I don't think that will work in a html file, it'll have to be a php file. Either that or have your server parse html files as php, you can do that with a few .htaccess lines I think.
     
    mdvaldosta, Dec 28, 2005 IP
  5. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #5
    AddType application/x-httpd-php .php .html


    in .htaccess
     
    noppid, Dec 28, 2005 IP
  6. n0other

    n0other Peon

    Messages:
    146
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Well, it's just a matter of file extension, but I agree, it is worth to be mentioned.
     
    n0other, Dec 28, 2005 IP
  7. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #7
    It's being mentioned cause it's necessary. html files will just spit out the php as text if the handler is not declared.
     
    noppid, Dec 28, 2005 IP
  8. scopeweb

    scopeweb Guest

    Messages:
    494
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #8
    The first reply did not work ( inserting <?php include('path/to/your/script.php'); ?>)
     
    scopeweb, Dec 28, 2005 IP
  9. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #9
    It won't unless you apply the suggestions in post 4 and 5 as well as your php code is correct.
     
    noppid, Dec 28, 2005 IP
  10. livingearth

    livingearth Well-Known Member

    Messages:
    1,470
    Likes Received:
    83
    Best Answers:
    0
    Trophy Points:
    140
    #10
    As suggested over the previous posts you have two choices...

    You can make the html page you have work by changing the file extension from ".html" to ".php". Note you will have to change all links pointing to the page to the php file extension as well. Simply change the name from "yourpage.html" to "yourpage.php"
    Alternatively you could leave the page file extension the same and create a .htaccess file in the same directory and place the following info provided by noppid in the file...

    AddType application/x-httpd-php .php .html

    that should get you up and running...
     
    livingearth, Dec 28, 2005 IP
    noppid likes this.
  11. scopeweb

    scopeweb Guest

    Messages:
    494
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #11
    I changed the page from htm to php and the script worked inside the web page. Good up to there But!

    The PHP script is a keyword generater ( 3 files- index.php, keyword.php and a download php.) Once I submit a keyword the results do not appear. how would I make the results appear inside another page?
     
    scopeweb, Dec 28, 2005 IP
  12. livingearth

    livingearth Well-Known Member

    Messages:
    1,470
    Likes Received:
    83
    Best Answers:
    0
    Trophy Points:
    140
    #12
    Post or PM me a link or send me the php files in a PM. I`ll check it out...
     
    livingearth, Dec 28, 2005 IP
  13. scopeweb

    scopeweb Guest

    Messages:
    494
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #13
    email sent.

    Thanks
     
    scopeweb, Dec 28, 2005 IP
  14. jimrthy

    jimrthy Guest

    Messages:
    283
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Why not keep this public? This is a good thread. Lots of good knowledge that's probably being shared behind the scenes. Threads like this one are the reason this forum's such a great resource.

    No, sorry, I don't actually have anything to add that's worth mentioning, at this point. I haven't seen the details either :/
     
    jimrthy, Dec 28, 2005 IP
  15. scopeweb

    scopeweb Guest

    Messages:
    494
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Thread is still public, livingearth is just taking a look at the files involved; Hopefully he will have more to add.

    Thanks
     
    scopeweb, Dec 28, 2005 IP
  16. jimrthy

    jimrthy Guest

    Messages:
    283
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Does this mean that IM didn't help you?

    Then again, your message implies other issues. You have "an already prepared web page." Is this a straight HTML page?

    You probably need to change the suffixes in your site and add something like
    
    require_once("something.php");
    DoSomething();
    
    Code (markup):
    to all your pages. You also need to redirect all your HTML pages to the new PHP pages. (301, I think)

    Does the pre-prepared site already use PHP? Much easier. Just add the new script to your page and call it.

    Or do you have a bunch of CGI scripts running python/perl, and you need to add in a PHP script? That might actually be interesting.

    Choices, choices. CORBA? XMLRPC? What other options do people suggest?

    Or am I 100% off-base here? (It *has* happened before. Once or twice...)
     
    jimrthy, Dec 28, 2005 IP
  17. jimrthy

    jimrthy Guest

    Messages:
    283
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Are the files so private they can't be attached? If they're so big that attaching them here is a problem, you probably have at least one other basic problem.
     
    jimrthy, Dec 28, 2005 IP
  18. scopeweb

    scopeweb Guest

    Messages:
    494
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #18
    I got some PHP scripts, one was a (keyword suggester - index.php, keyword.php download.php) to run on a site that I'm working on. I need the scripts to run inside a web page that I have pre-prepared. still with me?

    Ok, I changed the htm page to a PHP page and added this code where I wanted the script to display - <?php include('path/to/your/script.php'); ?>

    The index.php showed up on the page allowing me to enter a keyword. BUT when I press the submit button the next event does not display (ie:the suggested keywords)

    How do I resolve this problem?:confused:
     
    scopeweb, Dec 28, 2005 IP
  19. scopeweb

    scopeweb Guest

    Messages:
    494
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #19
    Can anyone help?
     
    scopeweb, Dec 31, 2005 IP