Why is my mssql query failing?

Posted by Eric Reynolds on Stack Overflow See other posts from Stack Overflow or by Eric Reynolds
Published on 2010-06-02T13:58:31Z Indexed on 2010/06/02 14:03 UTC
Read the original article Hit count: 591

Filed under:
|
|
|
    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 software.software_dbo.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;
}

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:

Warning: mssql_query() [function.mssql-query]: message: Invalid object name 'Issues'. (severity 16) in /srv/www/htdocs/agreement.php on line 47

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

Warning: mssql_fetch_assoc(): supplied argument is not a valid MS SQL-result resource in /srv/www/htdocs/agreement.php on line 48

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

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

Warning: mssql_query() [function.mssql-query]: Query failed in /srv/www/htdocs/agreement.php on line 51

Warning: mssql_fetch_assoc(): supplied argument is not a valid MS SQL-result resource in /srv/www/htdocs/agreement.php on line 52

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.

Any help would be appreciated.

Thanks,

Eric R.

© Stack Overflow or respective owner

Related posts about php

Related posts about sql