Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Mphammad Arifi
Mphammad Arifi
147 Points

save as index.php not working link path folder such as style.css not working

Hi everyone save as : Index.php not coming as a local host internet. instead, taking me to visual studio??

Mphammad Arifi
Mphammad Arifi
147 Points

Thank you

1-Even that link, not taking me to localhost? it says: This site can’t be reached

localhost refused to connect. ERR_CONNECTION_REFUSED Am i need to download WordPress?

2 Answers

Nattapol Kamolbal
Nattapol Kamolbal
15,528 Points

Don't understand your question. For what I guest, you want to ask that "When I double click on index.php file the file opened with Visual Studio. How can I opened it in the browser?"

If that the case, you can open php file on browser using right click >>> open with >>> your browser choice. But PHP is server-side language so the php code won't run. (only client-side language like html, css, javascript will run on the browser) You have to install the local server on your computer (like XAMPP, MAMP, WAMP).

About your css file not working, you have to provide more detail. (look at Markdown Cheatsheet for how to post your code.) Maybe you have a typo. Maybe wrong file directory. Maybe wrong syntax. Maybe your css is associated with php so it's not working.

Mphammad Arifi
Mphammad Arifi
147 Points

Thank you!

1- There is Web server: Xamp, which both Apache for PHP and MYSQL running. but i can't get into localhost? i changed the Regedit admin: net user. but still not working.

Nattapol Kamolbal
Nattapol Kamolbal
15,528 Points

Try this. Create new folder in htdoc and move you index.php file to that folder. (Try the basic file first to rule out typo or syntax error.) Then access it by typing "http://localhost/YOURFOLDERNAME" (replace YOURFOLDERNAME with your actual folder name).

You may also need to add port to your url, for example, http://localhost:80/YOURFOLDERNAME.

If this don't worked, see if the XAMPP console has errors or not.

Nattapol Kamolbal
Nattapol Kamolbal
15,528 Points

Response to your comment:

Thank you 1-Even that link, not taking me to localhost? it says: This site can’t be reached localhost refused to connect. ERR_CONNECTION_REFUSED Am i need to download WordPress?

My answer:

First of all, you don't have to download WordPress in order to successfully use XAMPP. The simple php file like this should run.

<?php
    echo "hello world";
?>

Second, for your given information, the error code is a bit vague and can caused by a lot of factors. Try reinstall XAMPP and access localhost again without editing any files in htdoc. If that don't help, try WAMP instead.

More, one issue that I found when installing XAMPP is that the default port 80 which Apache used is used by Skype and I can't access the localhost, the resolution is changing the port to 8080 (or something else). But the error message differ from your case so I'm not sure if this is your problem or not.

Mphammad Arifi
Mphammad Arifi
147 Points

Thank you.

1_ XAMP Apache and MySQL both in green. and "start". but local host to set the root directory not coming up ?

2- when i save , in a root directory: htdocs: index.php just browse google chrome, only inputting as i typed in. not outputting .