1. #1

    Help with PHP

    Sorry for the noob question but why this doesn't work?
    Here is what I put in Notepad:
    <html>
    <head>
    <title>Home</title>
    </head>
    <body>
    <?php echo "Hello World"; ?>
    </body>
    </html>
    I save as index.php
    And when I open with Google Chrome it justs downloads. What did I do wrong, or maybe I need to download something, although this works: http://www.redlynxtrials.com/Highsco...rackId=2567727 and it's PHP, I think.
    Share this post

  2. #2
    sipe's Avatar Trials Developer
    Join Date
    Dec 2012
    Location
    Helsinki, Finland
    Posts
    455

    Re: Help with PHP

    Seems that you running on local machine? Do you have PHP installed correctly if so?

    You can easily test you php configurations with simple line.

    <?php phpinfo(); ?>

    It should print PHP configurations if PHP is installed, if it's blank you have something wrong with your configurations or PHP is not installed.

    Still not working and you think you have all those tools installed, try other browsers like Opera, firefox, IE for example.

    Edit. And Trials 2 statistics pages, made with JSP not PHP but it's irrelevant
    Share this post

  3. #3

    Re: Help with PHP

    What sipe said You have to have php installed on a webserver. You can't just drag your site to a browser window. It has to be parsed by php. You have two ways to do that:

    A: Use your regular webspace, upload your file and try it out or
    B: Install WAMP (Windows w/ Apache, MySQL, PHP) on your computer and put your files into a folder in /htdocs/. To test them open your favorite browser and type in 127.0.0.1(or:localhost)/your-folder/your-file.php and it should work if everything has been done right.
    Share this post

  4. #4

    Re: Help with PHP

    @lu3mm3l and RK360 put the PHP files in C:\wamp\www or if you didn't install it to the default place then *:\wamp\wamp . See what I mean? Thats good
    Share this post

  5. #5

    Re: Help with PHP

    Originally Posted by Hughsie
    @lu3mm3l and RK360 put the PHP files in C:\wamp\www or if you didn't install it to the default place then *:\wamp\wamp . See what I mean? Thats good
    Oh, it is /www/ on windows? I thought it was /htdocs/ but I haven't used windows for 2 years now. Best thing for development is to edit the httpd.conf and set your current directory you're working with as path. You could also use the buildin Microsoft IIS and the php plugin but Apache is easier to use for beginners

    @Hughsie
    Trust me, I know where to put my files. I've been using php for about 9 years now
    Share this post

  6. #6

    Re: Help with PHP

    Originally Posted by lu3mm3l
    What sipe said You have to have php installed on a webserver. You can't just drag your site to a browser window. It has to be parsed by php. You have two ways to do that:

    A: Use your regular webspace, upload your file and try it out or
    B: Install WAMP (Windows w/ Apache, MySQL, PHP) on your computer and put your files into a folder in /htdocs/. To test them open your favorite browser and type in 127.0.0.1(or:localhost)/your-folder/your-file.php and it should work if everything has been done right.
    I installed this: http://www.wampserver.com/en/download.php. And then put them in C:/wamp/www/index.php. And I opened them with Google Chrome and IE and it still downloads it. And when I went to http://localhost/ I get a page with a title of Home, it says "Hello World". I think I created that. Oh and did you guys create redlynxtrials.com with Photoshop like this: http://www.tutorial9.net/photoshop/c...-in-photoshop/ then did this: http://www.tutvid.com/tutorials/phot...ingALayout.php to bring it to html?
    Share this post

  7. #7

    Re: Help with PHP

    Originally Posted by RK360
    I installed this: http://www.wampserver.com/en/download.php. And then put them in C:/wamp/www/index.php. And I opened them with Google Chrome and IE and it still downloads it. And when I went to http://localhost/ I get a page with a title of Home, it says "Hello World". I think I created that.
    You're kidding me, right? Isn't "Hello World" what you wanted in the first place? Your Script should do exactly what you just wrote. You HAVE to open every PHP site via "localhost" or it will not be interpreted by PHP. You can't just drag a file into IE or Chrome. Thats for the core programming. For design issues you should install Firefox & Opera too because they display some stuff different.

    Originally Posted by RK360
    Oh and did you guys create redlynxtrials.com with Photoshop like this: http://www.tutorial9.net/photoshop/c...-in-photoshop/ then did this: http://www.tutvid.com/tutorials/phot...ingALayout.php to bring it to html?
    Looks that way but you can make layouts like that with freeware or cheaper programs too. Like Paint Shop Pro and some Freeware to slice it or maybe they even included something like that now. I don't know. I like it slimmer but that a personal preference.
    Share this post

  8. #8

    Re: Help with PHP

    Originally Posted by lu3mm3l
    Originally Posted by RK360
    I installed this: http://www.wampserver.com/en/download.php. And then put them in C:/wamp/www/index.php. And I opened them with Google Chrome and IE and it still downloads it. And when I went to http://localhost/ I get a page with a title of Home, it says "Hello World". I think I created that.
    You're kidding me, right? Isn't "Hello World" what you wanted in the first place? Your Script should do exactly what you just wrote. You HAVE to open every PHP site via "localhost" or it will not be interpreted by PHP. You can't just drag a file into IE or Chrome. Thats for the core programming. For design issues you should install Firefox & Opera too because they display some stuff different.

    Originally Posted by RK360
    Oh and did you guys create redlynxtrials.com with Photoshop like this: http://www.tutorial9.net/photoshop/c...-in-photoshop/ then did this: http://www.tutvid.com/tutorials/phot...ingALayout.php to bring it to html?
    Looks that way but you can make layouts like that with freeware or cheaper programs too. Like Paint Shop Pro and some Freeware to slice it or maybe they even included something like that now. I don't know. I like it slimmer but that a personal preference.
    Thanks for the help ! But can I test individual pages instead of the index.php linking them to it? Do you know if Gimp has the slicing option?
    Share this post

  9. #9

    Re: Help with PHP

    Originally Posted by RK360
    Thanks for the help ! But can I test individual pages instead of the index.php linking them to it?
    Depends on your PHP editor. Some let you setup your local settings for your apache so if you press preview the browser opens directly localhost/yourfile.php. One of those would be "Phase 5" which should be available in english too. The easier way is enabling directory listing in apache and leave out the index.php. This way you see all files listed when browsing to localhost. And the last (more advanced) option would be integrated debugging. The better editors include a PHP debugger to find your errors in the source code. But those aren't free. At least not those I know.

    Originally Posted by RK360
    Do you know if Gimp has the slicing option?
    AFAIK no. But I haven't used it in a long time so try it yourself, maybe they added something like that.
    Share this post

  10. #10

    Re: Help with PHP

    I still have nightmares about Photoshop layouts. They are horrible to build.
    Share this post