title: Why is my SQL Server query failing?
body: <pre><code> connect();
   $arr = mssql_fetch_assoc(mssql_query("SELECT Applications.ProductName,
          Applications.ProductVersion, Applications.ProductSize, 
          Applications.Description, Applications.ProductKey, Applications.ProductKeyID,
          Applications.AutomatedInstaller, Applications.AutomatedInstallerName,
          Applications.ISO, Applications.ISOName, Applications.Internet,
          Applications.InternetURL, Applications.DatePublished, Applications.LicenseID,
          Applications.InstallationGuide, Vendors.VendorName
  FROM Applications
  INNER JOIN Vendors ON Applications.VendorID = Vendors.VendorID
  WHERE ApplicationID = ".$ApplicationID));
  
  $query1 = mssql_query("SELECT Issues.AppID, Issues.KnownIssues
        FROM Issues 
        WHERE Issues.AppID=".$ApplicationID);   
  $issues = mssql_fetch_assoc($query1);
  $query2 = mssql_query("SELECT ApplicationInfo.AppID,
                 ApplicationInfo.Support_Status, ApplicationInfo.UD_Training,
                 ApplicationInfo.AtomicTraining, ApplicationInfo.VendorURL
     FROM  ApplicationInfo
     WHERE ApplicationInfo.AppID = ".$ApplicationID);
  $row = mssql_fetch_assoc($query2);
  function connect(){
   $connect =  mssql_connect(DBSERVER, DBO, DBPW) or 
          die("Unable to connect to server");
   $selected = mssql_select_db(DBNAME, $connect) or 
          die("Unable to connect to database");
   return $connect;
  }
  </code></pre>
  
  <p>Above is the code. The first query/fetch_assoc works perfectly fine, however the next 2 queries fail and I cannot figure out why. Here is the error statement that shows up from php:</p>
  
  <blockquote>
    <p>Warning: mssql_query() [function.mssql-query]: message: Invalid object name 'Issues'. (severity 16) in /srv/www/htdocs/agreement.php on line 47</p>
    
    <p>Warning: mssql_query() [function.mssql-query]: General SQL Server error: Check messages from the SQL Server (severity 16) in /srv/www/htdocs/agreement.php on line 47
    Warning: mssql_query() [function.mssql-query]: Query failed in /srv/www/htdocs/agreement.php on line 47</p>
    
    <p>Warning: mssql_fetch_assoc(): supplied argument is not a valid MS SQL-result resource in /srv/www/htdocs/agreement.php on line 48</p>
    
    <p>Warning: mssql_query() [function.mssql-query]: message: Invalid object name 'software.software_dbo.ApplicationInfo'. (severity 16) in /srv/www/htdocs/agreement.php on line 51</p>
    
    <p>Warning: mssql_query() [function.mssql-query]: General SQL Server error: Check messages from the SQL Server (severity 16) in /srv/www/htdocs/agreement.php on line 51</p>
    
    <p>Warning: mssql_query() [function.mssql-query]: Query failed in /srv/www/htdocs/agreement.php on line 51</p>
    
    <p>Warning: mssql_fetch_assoc(): supplied argument is not a valid MS SQL-result resource in /srv/www/htdocs/agreement.php on line 52</p>
  </blockquote>
  
  <p>The error clearly centers around the fact that the query is not executing. In my database I have a table called Issues and a table called ApplicationInfo so I am unsure why it is telling me that they are invalid objects.</p>