Sunday, February 27, 2011

Connection database in PHP

Before make the full website, we must know about HTML code. I think it is very easy. You can study by your self about HTML code. Now we want to make database connection with PHP. To connect with database, first you must make the connection code with php to connect database.


The connection code for standard connection with mysql




<?php
mysql_connect("server name","user name","password");
mysql_select_db("database");
?>

------------------------------------------------------------------------------------    
note:
  • change your server name with your web hosting server name
  • change username with your username
  • change password with your database password
  • Change database with your database name

Now, we try to use the coding For this case I use localhost as my server,root as my username,dbtes as my database and no password in my database..So the connection cose we use like below





<?php
mysql_connect("localhost","root","");                                                            
mysql_select_db("dbtes");
?>


After your type all of the code,save the code as .inc extension to make more secure. Notice that don't use .php extension

No comments:

Post a Comment

web programming