2 Replies Latest reply on May 12, 2015 8:25 AM by TSGal

    Parameter Based PHP ODBC Query - Invalid Descriptor Index

    RobertLaRoe

      Title

      Parameter Based PHP ODBC Query - Invalid Descriptor Index

      Post

      Hi Everyone,

      A problem driving me up the wall - I would like to perform a simple parameter based insert into FileMaker using ODBC/PHP. Here is my query:

      Code:
          
      $_sql = '
              INSERT INTO
                  dbo_dbg
                  (
                      aString, aNumber
                  ) VALUES (
                      ?, ?
                  )
      ';
      $exec_data = array(
              'abc',
              500
          );


      This produces the error '[FileMaker][FileMaker] Invalid descriptor index'. If I insert a single value ala:

      Code:
          
      $_sql = '
      INSERT INTO
        dbo_dbg
      (
        aString
      ) VALUES (
        ?
      )
      ';
      $exec_data = array(
        'abc',
      );


      It works fine. I've tried a single value insert with a number and date for good measure. No problem. I feel like this is an issue with ODBC and goofy column numbers in FM as illustrated here:

      Code:
      $sth     = odbc_exec($conn, 'SELECT * FROM dbo_dbg') or db_log::error(odbc_errormsg(), true);    
      
      $x = 0;
      foreach($row as $col => $val) {
        echo odbc_field_name($sth, $x) . ', ' . odbc_field_type($sth, $x) . ', ' . odbc_field_num($sth, $col) . '<br />';
        $x++;
      }


      Result:

      , , 1
      aString, VARCHAR, 2
      aNumber, DECIMAL, 3


      I've been banging my head on this for a few hours. Any help is appreciated!