I just started reading up on PHP with mySQL, and I am just on the first page (http://php.about.com/od/phpwithmysql/ss/mysql_php.htm) and it says that I connect to my database within my PHP code by supplying my username and password.
My question is, would this not leave my password exposed for anyone to then access my database?
Now I have not learned yet if this connection code is written in a separate php file, or in php inbedded into my html code, but aren't all my files (php, css, js), all available anyways; otherwise how would people's browsers be able to see the results?
No. PHP is processed on the server-side, and is never sent (insecure application not withstanding) to the browser. You might also check out CodeAcademy's PHP track. I think that would probably be a better guide for you!