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
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); ?>
Related Q & A:
- Are SQL Injection vulnerabilities in a PHP application acceptable if mod_security is enabled?Best solution by Programmers
- How to connect Sql Server Database from android app?Best solution by Stack Overflow
- How to prevent an SQL injection in PHP?Best solution by Stack Overflow
- How to convert my SQL query to MS Access query?Best solution by Stack Overflow
- How do I connect to a SQL Server database?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.