Tuesday, October 16, 2012

FreeTDS MYSQL MSSQL PHP

You certainly know a wide range of database engine in the world. one of which is MYSQL.
My post this time about the experience of using the connector from MYSQL ubuntu server to MSSQL the course of microsoft. The goal is to read data from MSSQL database using PHP commands in a project I was working on. The first one is the installation of freetds package ubuntu package, by typing the command:
sudo apt-get install freetds-common freetds-bin unixodbc php5-sybase 
Once the process is complete, do the changes in the file freetds.conf use the command:
sudo vim /etc/freetds/freetds.conf then add some few lines at the bottom of the file: 
[yourserver] host = your.server.name 
port = 1433 
tds version = 8.0 
Furthermore restart the apache server on the machine by typing the command:
sudo /etc/init.d/apache2 restart 
The final step, create additional php file that is created as follows:
<? php
$ link = mssql_connect ('yourserver', 'yourusername', 'yourpassword');
if (!$link) { die ('Unable to connect!'); }  
if (!mssql_select_db ('yourdatabasename', $ link))
{ die ('Unable to select database'); }
$result = mssql_query ('SELECT * FROM yourtable');  
while ($row=mssql_fetch_array ($ result)) { var_dump ($ row); }  
mssql_free_result ($ result);
?>
Mysql database result has been able to read the data on MSSQL database. Furthermore, good luck, good luck

2 comments:

  1. Really like that you are providing such information on PHP MYSQl with JAVASCRIPT ,being enrolled at http://www.wiziq.com/course/5871-php-mysql-with-basic-javascript-integrated-course i really thank you for providing such information it was helpful.

    ReplyDelete
  2. Thank you for your response, if there are more solutions with regard to the above, please share it with us

    ReplyDelete