I am a newbie in PHP.I have written some php scripts, but as many of DP members said I need to code the database connection in another file so that it is more secure.So how can I do that. Is it simply code the db connection in config file and include it to any file where I need the db connection ??? I have seen a file type in most of the php projects with extension .inc.php.What is this ? I have coded some DB projects and works fine on my system but I can't work it fine on my hosting space.How to connect to db in host ??? I use : But what is this user and password in hosting space ? I have created one database,user,password with phpmyadmin and give it but no use. In my project I am taking the user name,password and servername from input box and create a db but in hosting space I need to create database name first ??
I've written a post in my blog: http://www.itamer.com/secure-file-locations/72/ I'd recommend that the database connection script is held below the public directory. That way the script can't be called from a browser. The same goes for any password or config files.