Page 1 of 1

odbc_fetch_array() does not work?

Posted: Fri Aug 21, 2009 2:21 pm
by general_ludd
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.

Code: Select all

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);
    $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!

Re: odbc_fetch_array() does not work?

Posted: Mon Aug 24, 2009 12:59 pm
by akuji36
odbc_fetch_row
odbc_num_rows
odbc_fetch_array
odbc_num_fields

I have used mysql in place of "odbc":

example mysql_fetch_row

follow these links:for mysql_fetch_row

http://www.w3schools.com/php/func_mysql_fetch_row.asp



and for mysql_num_fields

http://z505.com/powtils/docs-mysql/mysq ... field.html


Here a few entertaining mysql & php video tutorials that will help you out:

http://www.phpvideotutorials.com/free
http://www.phpvideotutorials.com/free

Re: odbc_fetch_array() does not work?

Posted: Mon Aug 24, 2009 4:26 pm
by general_ludd
Thanks for the tips. I am fairly experienced when it comes to mysql, unfortunately, this particular project requires that I communicate with an Access database, and ODBC seems like the most efficient and direct way to do this. I have been able to get ODBC to work before and can't for the life of me figure out why it isn't working this time.

Re: odbc_fetch_array() does not work?

Posted: Mon Aug 24, 2009 6:00 pm
by akuji36
Could it be a driver issue?? I used 3.51 at one time

now i think it's up to 5.1.

Re: odbc_fetch_array() does not work?

Posted: Mon Aug 24, 2009 6:11 pm
by general_ludd
Is there a way to safely downgrade the drivers or add the older ones?