Page 1 of 1

Issues with PHP and ODBC xBase

Posted: Thu 29 Mar 2018 01:44
by SoN9ne
I am testing this out for a project that uses VisualFoxPro (9). I am not able to get this working for PHP5.4. If all goes well, I plan to update PHP but until then I need 5.4 to use ADODB for foxpro but I digress...

Everything installed fine without an issue. I setup the ODBC and ran a test connection and everything was fine.

I tested it out, using my script below, and it wanted a .CDX file (I only used .dbf for the adodb system. I am hoping this will be much faster than that). I then downloaded the entire foxpro folder and updated my content with this fresh dump. I had to reboot my computer due to a non-related issue and now when I click test, I get this error:

Code: Select all

Access violation at address 000007FEF2C6A056 in module 'odbc32.dll'. Read of address 000000000000000000
When running my PHP script, I get:

Code: Select all

Warning: odbc_connect(): SQL error: [Devart][ODBC][xBase]Error: FileStream.Size 0, readed 0, SQL state 08001 in SQLConnect in M:\__LOCATION__\public_html\_cron\test.php on line 6
I'm posting this here as I continue to look for the issue. Hoping it's something trivial but I wanted to make note.

I have tested using:

Code: Select all

DBF Format=FoxPro2;
and

Code: Select all

DBF Format=VisualFoxPro
and I get the same errors.

My script:

Code: Select all

    $dsn = 'DRIVER={Devart ODBC Driver for xBase};Database=M:\__LOCATION__\public_html\_cache\VP10\PRAXIS\;DBF Format=VisualFoxPro;Code Page=UnitedStatesOEM;Connect Mode=Exlusive';
    $conn = odbc_connect($dsn, '', '');
    if (false === $conn) {
        die('ODBC Connection Failed');
    }
    $sql = "SELECT custno, company FROM arcust01 WHERE company <> '' ORDER BY custno;";
    $rs=odbc_exec($conn,$sql);

    while (odbc_fetch_row($rs)) {
        $custno=odbc_result($rs,"custno");
        $company=odbc_result($rs,"company");
        echo '<ul>';
        echo '<li>';
        echo "<strong>{$custno}: </strong>";
        echo $company;
        echo '</li>';
        echo '</ul>';
    }

    exit();
    
I also want to make note that when I used just the alias:

Code: Select all

$conn = odbc_connect('Praxis', '', '');
I get the error:

Code: Select all

Warning: odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application, SQL state IM014 in SQLConnect in M:\__LOCATION__\public_html\_cron\test.php on line 50
ODBC Connection Failed
I am using Windows 7 64bit (obviously php5.4 is running as 32bit) but this will be installed on Windows Server 2008 (possibly the latest version if not that) when it goes into production.

Re: Issues with PHP and ODBC xBase

Posted: Thu 29 Mar 2018 09:10
by azyk
Please use the contact form at our site: https://www.devart.com/company/contactform.html and send us the arcust01 table files ( arcust01.dbf and arcust01.cdx ) to reproduce the issue.