Board index   FAQ   Search  
Register  Login
Board index php forum :: Database Other Database Engines

Error while connecting with SQL Server

Do you have questions regarding other database enginges (not MySQL) -- ask here!

Moderators: macek, egami, gesf

Error while connecting with SQL Server

Postby indiavitus » Sun Jul 03, 2011 9:54 pm

Hi,

I am not able to connect to SQLServer database hosted on some other machine.
I am using the following code to do this:

<?php
$myServer = "192.168.0.13";
$myUser = "sa";
$myPass = "test123";
$myDB = "Test_DBSchema";

//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");

//declare the SQL statement that will query the database
$query = "SELECT count(*) from test";
//Name, Address, City

//execute the SQL query and return records
$result = mssql_query($query);

$numRows = mssql_num_rows($result);
echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";

//display the results
while($row = mssql_fetch_array($result))
{
echo "<li>" . $row["id"] . $row["name"] . $row["year"] . "</li>";
}
//close the connection
mssql_close($dbhandle);
?>


Please suggest me.

Thanks,
Manoj Singh
indiavitus
New php-forum User
New php-forum User
 
Posts: 7
Joined: Wed Sep 01, 2010 2:24 am

Re: Error while connecting with SQL Server

Postby egami » Tue Jul 05, 2011 7:01 am

Any errors ?
Timeouts?

Hard to help, with out any debugging!
User avatar
egami
php-forum GURU
php-forum GURU
 
Posts: 2197
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: Error while connecting with SQL Server

Postby boybawang » Mon Apr 16, 2012 3:20 pm

if you are encountering this problem with the code your using then it may have something to do with the server. Try other options or you may just contact some professional service for your database.
boybawang
New php-forum User
New php-forum User
 
Posts: 30
Joined: Fri Mar 02, 2012 12:38 am
Location: Australia


Return to Other Database Engines

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.