I can get the DB connect to work. I can query data in the master database. How do I make it query for data in databases other than master?
$hostname = "myserver";
$username = "sa";
$password = "password"; // so its insecure
$dbname = "master";
//$dbname = "therealtableIwant";
$this->dbconnection = mssql_connect($hostname, $username, $password) or DIE("DATABASE FAILED TO RESPOND.");
$result = mssql_select_db($dbName, $this->dbconnection) or DIE("Table unavailable");
$query = "SELECT name FROM sysobjects WHERE type = 'U'";
$result = MSSQL_QUERY($query, $this->dbconnection);
$number = MSSQL_NUM_ROWS($result);
$i=0;
while ($i < $number)
{
$name = mssql_result($result ,$i , "Name");
print $name."<br>\n";
$i++;
}
Die("Program stopping");
If I change the $dbname to the name of the database I actually want I get an "Unable to select database" error.
This occurs with all user accounts, irrespective of rights.
Why am I so stupid I can't work this out?
What is the answer?
Alistair...