www.pickatutorial.com Computer Tutorials
Top Tutorials: C/C++ | C#.NET | PHP MySQL | Java | Java Script | jQuery | HTML | xHTML | HTML5 | VB Script| CSS
Lessons PHP Built-In MySQL Functions Bookmark and Share
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Lesson 9
Lesson 10
Lesson 11
Lesson 12
Lesson 13
Lesson 14
Lesson 15
Lesson 16
Lesson 17
Lesson 18
Lesson 19
Lesson 20
Lesson 21
Lesson 22
Lesson 23
Lesson 24
Lesson 25
Lesson 26
Lesson 27
Lesson 28
Lesson 29
Lesson 30
Lesson 31
Lesson 32
Lesson 33
Lesson 34
Lesson 35
Lesson 36
Lesson 37
Lesson 38
Lesson 39
Lesson 40
Lesson 41
Lesson 42
Lesson 43
Lesson 44
PHP provides numerous built-in fuctions for working with MySQL database server. In this lesson we are going to introduce some of the most important of them.

The mysql_connect() function opens a connection to the MySQL database server. It needs has three parameters namely; server name, username, and password. Its syntax follows:

$connection = mysql_connect("servername","username","password");

The mysql_select_db() function is used to select an existing database on the MySQL server for subsequent use by the PHP script. It requires two arguments; database name and a valid reference to the MySQL database server. Its syntax follows:

$db = mysql_select_db("myDB", $connection);

This function is used to execute SQL commands and statements. It requires an open connection to the database. Its syntax follows:

$sql_result = mysql_query("SELECT * FROM SOMETABLE", $connection);

The mysql_error() function returns a meaningful error message when something goes wrong with our connection or query. Generally it is used in the context of the die() function. Its syntax follows:

$sql_result = mysql_query("SELECT * FROM SOMETABLE", $connection)
or die(mysql_error());

This function is used to get a record from the recordset in the form of an array. Its syntax follows:

$row = mysql_fetch_array($sql_result);

This function is generally used to get the number of rows in a result set. Its syntax follows:

$num = mysql_num_rows($sql_result);

Home - Advertise - Contact - Disclaimer - About Us
© Since 2006 pickatutorial.com -- All Rights Reserved.