pTutorial

New way to learn Programming

PHP Function

In this tutorial we will focus on PHP MYSQL functions like MYSQL_connect, MYSQL_select_db, MYSQL_close($link) etc.

PHP provides a lot of predefined MYSQL functions to connect to the MYSQL database and manipulate the data from MYSQL database.

You can easily call PHP MYSQL function like normal PHP function. Some of all are following below

Syntax


MYSQL_connect(server, user, pass, new_link, client_flag);

Parameter Description
Server Url or ip of the MYSQL server(optional)
User User name of the MYSQL server(optional)
Pass User name of the MYSQL server(optional)
New_link default: FALSE, no new link on second call(optional)
Client_flag $integer(optional)

Note: Always use die function for security purpose.

Definition

It returns true if it successfully connected to the database server otherwise return false.

Usage

mysql_connect() is basically used to Establishes the connection to the MySQL server located at server and using the permissions provided by the username and password.

Example of die function

<?php

$con = mysql_connect('localhost', 'root', '') 
or die('Could not connect to the MYSQL DB');
if($con)
{
echo "Connected successfully"; 
}
else
{
echo "Error occur ";
}

?>



Output

Connected successfully


QUOTES OF THE DAY

Whenever man commits a crime,heaven finds a witness.

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER