We have talked about how to make database connections in PHP before. However, I realized that I have forgotten something which is so important. If you read that article or you are interested in PHP, you may know that we use odbc_connect() or mysql_connect() (or etc.) functions to connect some databases. These functions try to connect to specified databases. I wish every request would be accepted, because it is possible getting errors during the process. If the connection is not successful, the rest of codes will not work properly. So today, I will show you how to check database connections.
It is so simple checking database connections in PHP. We need to know that Click to Read Complete Article »
1.1) MYSQL Connection in PHP
We can use mysql_connect and mysql_select_db functions to create our connections. For closing the connections there is mysql_close function. These are basic functions of managing connections in PHP. There are also a lot of classes made by developers for free.
Sturcture 1.0:
1 2 3 4 5
| <?php
$ConnectionName = mysql_connect('MyHost', 'MyLogin', 'MyPassword');
$DatabaseConnection = mysql_select_db('MyDatabaseName', $ConnectionName);
mysql_close($ConnectionName);
?> |
You can determine the
MyHost,
MyLogin,
MyPassword and
MyDatabaseName variables as you need.
Example 1.0: We used hostname:port syntax Click to Read Complete Article »
1.1) MSSQL ( Microsoft SQL Server ) Connection in ASP
Sturcture 1.1:
1 2 3 4
| < %
Set ConnectionName=Server.CreateObject("Adodb.Connection")
ConnectionName.Open "driver={SQL Server};server=MyHost;uid=MyLogin;pwd=MyPassword;database=MyDatabaseName"
%> |
You can determine the server, uid, pwd and database variables as you need.
Example 1.1:
1 2 3 4
| < %
Set MyConn=Server.CreateObject("Adodb.Connection")
MyConn.Open "driver={SQL Server};server=127.0.0.1;uid=memisologin;pwd=memiso;database=memisodb"
%> |
1.2) MDB ( Microsoft Access Database ) Connection in ASP
Click to Read Complete Article »
Before giving structures, we need to notice a little detail about making database connections in Java. All database connections must be stated in try and catch statements, because there is a possibility of getting an exception. That’s way, we try to make our connection in try statement. If our connection attempt fails, that means there is an exception, and the exceptions must be catched.
1.1) MS SQL Connection in Java
Example 1.1: MakingConnections.java Click to Read Complete Article »
Recently Typed