How to connect php file to ms access?

Connect to MS SQL in PHP?

  • So basically I have a PHP server that runs PHP all fine and I have a MS SQL server which has been used to host backends of Access Databases. Now we want to also have a web interface to this backend and I am trying connect to the database through PHP but can't seem to get it to work. Do I need to do something, here is the code I am using. $hostname = "\\PLYSVSQ017\"; $Username = "sa"; $Password = "password"; $DBname = "Test"; //connection to the database $dbhandle = mssql_connect($hostname, $Username, $Password) or die("Couldn't connect to SQL Server on $hostname"); Upon failure I don't even get the Couldn't connect error showing??

  • Answer:

    To access Microsoft Access, you need to use an ODBC connection from PHP. e.g $conn=odbc_connect('northwind','',''); $sql="SELECT * FROM customers"; $rs=odbc_exec($conn,$sql); Read more here http://www.w3schools.com/php/php_db_odbc.asp Need help in developing this, contact us at http://acsdb.com

Rupert M at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

To access Microsoft Access, you need to use an ODBC connection from PHP. e.g $conn=odbc_connect('northwind','',''); $sql="SELECT * FROM customers"; $rs=odbc_exec($conn,$sql); Read more here http://www.w3schools.com/php/php_db_odbc.asp Need help in developing this, contact us at http://acsdb.com

Cyrus

<?php // Server in the this format: <computer>\<instance name> or // <server>,<port> when using a non default port number $server = 'KALLESPC\SQLEXPRESS'; // Connect to MSSQL $link = mssql_connect($server, 'sa', 'phpfi'); if (!$link) { die('Something went wrong while connecting to MSSQL'); } ?>

Austin

<?php $conn = mysql_connect("localhost","root","") or die('error in connection'.mysql_error()); mysql_select_db("database",$conn); ?>

Jessica

<?php // Server in the this format: <computer>\<instance name> or // <server>,<port> when using a non default port number $server = 'KALLESPC\SQLEXPRESS'; // Connect to MSSQL $link = mssql_connect($server, 'sa', 'phpfi'); if (!$link) { die('Something went wrong while connecting to MSSQL'); } ?>

<?php $conn = mysql_connect("localhost","root","") or die('error in connection'.mysql_error()); mysql_select_db("database",$conn); ?>

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.