MySQL

From RadPHP XE2 Documentation
Jump to: navigation, search

Contents

Usage

Database Setup

To use a Database component with MySQL, set it up so it uses MySQL driver:

  • DriverName: mysql.

Do not forget to fill also the rest of the basic information.

Work With PHP

// Set Connection Data
$database = 'database';			// Database name.
$user = 'user';				// Username to access the database.
$password = 'password';			// Password for the user.
$server = 'server';			// Server address.
 
// Establish Connection
$connection = mysql_connect($server, $user, $password);
 
// Connection Test
if (!$connection)
    echo 'MySQL Server could not be reached';
else
    echo 'Succesfully connected to MySQL Server';
 
// Select a Database
if(mysql_select_db($database))
    echo 'Succesfully selected MySQL Database';
else
    echo 'MySQL Database could not be selected';
 
// Close Connection
mysql_close($connection);

See Also

 

Personal tools