Page 234 - Open Soource Technologies 304.indd
P. 234
Unit 14: Connecting to MySQL with PHP
Now that you have put the database configuration, opening and closing routines in separate Notes
files your PHP script that uses mysql would look something like this :
<?php
include ‘config.php’;
include ‘opendb.php’;
// ... do something like insert or select, etc
include ‘closedb.php’;
?>
14.2 Working with MySQL Data
14.2.1 Connecting to the Server
As mentioned earlier, MySQL operates in client/server architecture. The client application needs
to connect to database server, before manipulating the data.
For our examples, we will be using Telnet application to connect to the database server, and
manipulate the database. In the examples provided, we are using Windows OS with Telnet
client application. However, please note that there are other ways to connect to the database
server. Initially, you need to call the telnet application by issuing “telnet” command from your
DOS prompt. Now the telnet window pops up as shown below.
After clicking on the “Remote System”, the following window will come where you can give
the IP address of the server for connection
Then click the Connect button which will show the following window.
LOVELY PROFESSIONAL UNIVERSITY 229