#1
  1. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    758
    Rep Power
    125

    Invalid column name?


    I have the following query inside a php script:
    PHP Code:
    $student "
    SELECT
        *
    FROM
        studentclasses
    LEFT JOIN classes ON
        classes.ClassId = studentclasses.ClassId"
    ;

    $result mssql_query($student);
    $row mssql_fetch_array($resultMSSQL_ASSOC);
    print_r($row); 
    I check each table if they have the column ClassId and both tables have
    [ClassId] => 39546
    Why can't it find the ClassId column?

    When I run the query I receive the following PHP Warning: mssql_query(): messages:
    PHP Code:
    Invalid column name 'ClassId'. (severity 16in <path to scripton line 74
    Invalid column name 
    'ClassId'. (severity 16in <path to scripton line 74
    General SQL Server error
    Check messages from the SQL Server (severity 16in <path to scripton line 74
    Check messages from the SQL Server 
    (severity 16in <path to scripton line 74
    Query failed in 
    <path to scripton line 74
    Query failed in 
    <path to scripton line 74
    mssql_fetch_array
    () expects parameter 1 to be resourceboolean given in <path to scripton line 75
    mssql_fetch_array
    () expects parameter 1 to be resourceboolean given in <path to scripton line 75 
  2. #2
  3. Lord of the Dance
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Oct 2003
    Posts
    4,206
    Rep Power
    2012
    How does your table looks like?
    Can you display the Create statement for the tables?

IMN logo majestic logo threadwatch logo seochat tools logo