how to connect database using mysql - Learn With Riwash

Breaking

Learn With Riwash

learn with riwash learn with riwash is the personal blog/youtube channel that provide best knowledge of software development. Here we give complate trainning of techonology as will as build software. We teach you related to web developing and programming in html,javascript,php,python,c++, c#, java programming ect. It is not a complate teaching siti like W3schools but it it a blog where we give code that help you to become better programmer.

ads

Post Top Ad

Responsive Ads Here

Post Top Ad

Responsive Ads Here

Saturday, March 10, 2018

how to connect database using mysql



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 Top Ad

Responsive Ads Here