Hi all...
I need your help for to do a odbc conection....
I have a database in the other server and I need to connect there, I try to do with the code below but without sucess.
Please can you help me
$link = mssql_connect("server", "root", "pass");
if(!$link) {
echo’Could not connect’;
die(’Could not connect: ’ . mssql_error());
}
echo’Successful connection’;
mssql_close($link);
I try but doesn’t work....
the database is not mysql but sql.. it’ll be for this!?
Your code return me this error:
PHP error debug
Error: mysql_connect() [function.mysql-connect]: php_network_getaddresses: getaddrinfo failed: No such host is known.
Error type/ Nr.: Warning - 2
File: C:\wamp\www\real_estate\manager\includes\extenders\dbapi.mysql.class.inc.php
Line: 89
Line 89 source: if (!$this->conn = ($persist ? mysql_pconnect($host, $uid, $pwd) : mysql_connect($host, $uid, $pwd, true))) {
It’s an MS SQL DB?
Is the database server on the same machine as the web server hosting your site?
yes, it’s an MS SQL DB.
and the database is in a distinct host of my website
The code you are using should have worked then.
$myServer = "localhost";
$myUser = "your_name";
$myPass = "your_password";
$myDB = "examples";
//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn’t connect to SQL Server on $myServer");
//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn’t open database $myDB");
Do you get an error when u use this code?