Hi,
I predominantly use PHP with MySQL but have recently been needed to interact with MS SQL database for a client. I can connect to the server and run sp_databases and sp_tables to determin the higher structure however if I try to execute a simple SELECT command I run into errors. For example;
$link = mssql_connect("server_name","username","password");
$sql = "SELECT * FROM database_name.table_name;";
$res = mssql_query($sql, $link);
for($i=0; $i<mssql_num_fields($res, $link); $i++) {
$field = mssql_fetch_field($res, $i);
echo $field->name." | ".$field->type."<br />";
}
I get 3 error codes, the first being the most important which is "Invalid Object Name:...". I know this is an SQL error but I cannot seem to find the correct code to output anything. My goal is to first obtain the structure of the database, tables, columns and then pursue retrieving individual records.
Where am I going wrong?