Hello friends in this artical i am going to teach you about mysql database.
what is mysql and why we need ?
Sql is a database system that use in web and run in server . so mysql is needed for
collecting data.
Now here i teach you how to create and connect databas.
<?php
//this is sql database
$con = mysql_connect ("localhost", "root", "") or die("could not connect");
mysql_select_db("dbname") or die("could not find database please create db");
?>
$con is a variable that have a value of database connection.
why we write ("localhost", "root", "") in side mysql_connect?
mysql_connect is a code of mysql that for connect to database.
we write ("localhost" because we use our localserver database
"root" is username and in localserver we don't need password so we give "").
mysql_select_db selected database where database name is dbname .
If there didn't get database then it return that "could not find database please create db".
This is a way that how you create and connect to mysql database.

No comments:
Post a Comment