This is Ahad Aman. Today we are going learn how to connect to database using php.
So let's get started.
Also check my video tutorial if you learn that way better.
Full Code :
PHP Code:
Code:
<?php
$db = mysql_connect('localhost','root',' ');
mysql_select_db('tutorial',$db);
?>
localhost is my database host
root is my phpmyadmin username
and nothing is my password.
In the next line we tell the script to select the database.
In order to select the database it needs to login to the phpmyadmin,That is only the reason we attached $db with it.
SIMPLE ENOUGH!
Question of the day:
If we add mysql from other host and website from other host then it will work?
Answer : Definitely, You just need to give correct credentials.
This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.
Recommended article from FiveFilters.org: Most Labour MPs in the UK Are Revolting.
[Tutorial] How to connect to database in php
Aucun commentaire:
Enregistrer un commentaire