DATABASE CONNECTIVITY

Posted on Updated on

jikoDATABASE CONNECTIVITY

Connect the database we are use mysql_connect(),and select database we are use mysql_select_db(); for insert the query we are use mysql_query after the query we close the connection with mysql_close($connection_string);

Syntax:

Mysql_connect(“host name”,”user_name”,”password”);

Mysql_select_db(“database_name”);

Mysql_query(“query here”);

Mysql_close(“connection_string”);

When we are use connectivity we are use a php function which is die()

Die(): die function is use for stop the execution of the program.

We use mysql_error(); function is use to show the error of the mysql.

Syntax:

If(condtion)die(“error message”.mysql_error());

New version of mysql is mysqli:

Works is same but code is less and its works on php5.

Syntax:

                Mysqli_connect(“hostname”,”username”,”password”,”database_name”);

Mysqli_query(connection_string,”query here”);

Mysqli_close(connection_string);

Exp.

                <?php

$connection=Mysqli_connect(“localhost”,”root”,”abc”,”testing_database”);

                Mysqli_query($connection,”select * from table_name”);

Mysql_close($connection);

?>

For more details and queries please feel free to email, visit or call us. Wishing you the very best for all your future endeavors.

Helpline: 9814666333, 8699444666

Email:info@technocampus.co.in

**************************************************************************************************************

Please fill the FORM and we shall contact you soon.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s