Thursday, 15 August 2013

Connecting Microsoft SQL Server with PHP on Ubuntu

Here is how to get PHP 5.3 on Linux (specifically Ubuntu) talking to a Microsoft SQL Server database:

  1) Install FreeTDS and the PHP MS SQL extension

sudo apt-get install freetds-common freetds-bin unixodbc php5-sybase

  2) Restart Apache

sudo /etc/init.d/apache2 restart

  3) Configure FreeTDS

  Add this at the end of the file:
host =
port = 1433
tds version = 8.0
Test connection to the MSSQL server with this PHP script
 $server = 'your server name';
 $username = 'enter';
 $password = 'enter';
 $database = 'enter';
 $connection = mssql_connect($server, $username, $password);
 if($connection != FALSE)
  echo "Connected to the database server OK<br />";
  die("Couldn't connect");
 if(mssql_select_db($database, $connection))
  echo "Selected $database ok<br />";
  die('Failed to select DB');

 $query_result = mssql_query('SELECT @@VERSION');
 $row = mssql_fetch_array($query_result);
  if($row != FALSE)
  echo "Version is {$row[0]}<br />";


How to send SMS using PHP

How can I send SMS using PHP?
Actually this is easy process but for this you have to purchase an API to send SMS. But I have found a solution to show your project temporarily. I have an API that provides a free trial and allows to send 5 free SMS that is sufficient to show the project.

To integrate this you have to follow the following steps :

  1) Go to site, on this site click on free trial as follow :

2) You will get a simple form, fill that form and after submission you will get a mail which will contain username and password.
   3) Now download the sms api from Here

   4) Place this file into your project folder

   5)  Now put the following code in the file and send SMS :
   <form method=post action='srisms.php'>
   <table border=0>
      <td>Recipient no:</td>
      <td><input type='text' name='recipient'></td>
      <td><textarea rows=4 cols=40 name='message' maxlength="140"></textarea></td>
      <td> </td>
      <td><input type=submit name=submit value=Send></td>