I am running Apache2 for Windows, PHP 5.3.0 and have an Access database set up as a system DSN. I am able to send INSERTS, SELECTS, and other standard queries via ODBC, but the specific commands that do not work are any that might be useful in extracting multiple rows of data from the database. I can't figure out what is going on and I am really frustrated. The following commands do not work:
odbc_fetch_row
odbc_num_rows
odbc_fetch_array
odbc_num_fields
please note: I have no trouble with gaining access to the Database and submitting odbc_exec commands.

function createMenu($table,$value=NULL){
    $query="SELECT * FROM $table";
    $db_link=openDatabase();
    $result=odbc_exec($db_link,$query)or die(print odbc_errormsg());
    $count=recordCount($result); //this was a workaround bc odbc_num_rows() always returns -1
    $html[]="<select name='$table' id='$table'>";
    if($count>0){
        while(odbc_fetch_row($result)){
            $type_name=odbc_result($result,'type_name');
            $abbr=odbc_result($result,'abbr');
            $selected="";
            if($value==$abbr){
                $selected="selected";
            }
            $html[]="<option value='$abbr' $selected>$type_name</option>";
        }
        $html[]="</select>";
        $output=join("\n",$html);
        print $output;
    }
    odbc_close($db_link);
}

I'd love to be able to use a LAMP setup, but the project I am working on requires an mdb data source and must run on Windows.

Thanks for any help!

    5 days later

    They do not work because they have no meaning in Acesss/JET/mdb databases. Just because the ODBC driver spec sez that such functions exist, that does not mean that every ODBC source can support them. JET has little or none of the functionality associated with database engines, it is just an ISAM file handler really, and all the important work must be done by the client.

      But by all accounts it is supposed to work. What is an alternative? I have made this work in an older version and can't find very many complaints from other users about Access ODBC drivers and PHP so I assume I must be doing something wrong. Is there any hope that I might get this to work? I'm at my wit's end!

        6 days later

        I have discovered that the problem has much to do with the mdb file's security settings. It needs to include the system's Internet Guest Account (IUSR) and the Launch IIS Process Account (IWAM). It doesn't make any sense to me given that ODBC is the communication point and not the file itself, but once I made this change, it worked. I made no other changes to ODBC or to the file except this security change. Go, then figure.

          Write a Reply...