Results 1 to 12 of 12
  1. #1
    Join Date
    Jun 2007
    Posts
    6

    Unanswered: Problems with odbc connection

    Hi all,

    Does anyone know why I would be unable to connect via php / odbc to a Pervasive database? I can use isql to connect to pervasive and run queries, and I can use the php odbc functions with mysql, but I cannot use PHP / odbc with Pervasive. The result is a core dump.

    I am using Pervasive 9.10-020.000. I have tried both the rpm and tgz.
    Suse 10.1
    PHP 5.1.2
    unixODBC 2.2.11
    Linux 2.6.16.13

    Thanks

  2. #2
    Join Date
    Dec 2001
    Posts
    1,109
    Provided Answers: 4
    So if I understand correctly, your PSQL database is on the Linux server where PHP is running.
    Have you tried running PHP from the command line to execute the page that accesses the PSQL ODBC?
    What kind of PHP page have you tried? Is it simply an ODBC Connect or does it do more than that?
    Here's a page I've tried in the past that has worked:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>PHP Sample</TITLE>
    </HEAD>
    <BODY>
    <?php
    $conn=odbc_connect("Demodata","","",""); 
    $sql="select * from class";
    $rs=odbc_exec($conn,$sql);  
    echo "<table border=1>\n";
    $numfields = odbc_num_fields($rs);
    for($i=1;$i<=$numfields;$i++){
    	$fn=odbc_field_name($rs,$i);
    	echo "<th>$fn</th>";
    }
    echo "\n";
    while(odbc_fetch_row($rs)){ 
    	echo "<tr>\n";
    	for($i=1;$i<=$numfields;$i++){
    	   $fv=odbc_result($rs,$i);
    	   echo "<td>$fv</td>";
    	}   
    	echo "</tr>\n";
    } 
    echo "</table>\n";
    echo "<p>Number of Fields: $numfields</p>\n";
    ?>
    </BODY>
    </HTML>
    Does that work for you? It uses the PSQL DEMODATA database.
    Also, have you tried PSQL v9.5? It's the current version of PSQL and is a service pack for PSQL 9.10.
    Mirtheil Software
    Certified Pervasive Developer
    Certified Pervasive Technician
    Custom Btrieve/VB development
    http://www.mirtheil.com
    I do not answer questions by email. Please post on the forum.

  3. #3
    Join Date
    Jun 2007
    Posts
    6
    My apologies. PSQL is running on a Win2K3 server. I can use isql from the Linux command line to connect to the remote PSQL server, but cannot use PHP to connect.

    # cat test.php
    <?
    $conn = odbc_connect("Demodata", "", "");
    ?>

    # php5 test.php
    Segmentation fault (core dumped)

    # gdb php5 core
    > bt
    #0 0xb7c4bf6f in free () from /lib/libc.so.6
    #1 0xb6bf45d8 in MemFree () from /usr/lib/libtidy-0.99.so.0
    #2 0xb4abe7c1 in fStrGetPathName () from /usr/local/psql/lib/odbcci.so
    #3 0xb4abd5b0 in lenStrGetProfileString_priv () from /usr/local/psql/lib/odbcci.so
    #4 0xb4abe821 in lenStrGetProfileString () from /usr/local/psql/lib/odbcci.so
    #5 0xb4abeea9 in hTrcInit () from /usr/local/psql/lib/odbcci.so
    #6 0xb4a8f176 in hDrvTrcInit () from /usr/local/psql/lib/odbcci.so
    #7 0xb4a6f097 in _SimSQLConnect () from /usr/local/psql/lib/odbcci.so
    #8 0xb4a70106 in SQLConnect () from /usr/local/psql/lib/odbcci.so
    #9 0xb7032267 in SQLConnect () from /usr/local/psql/lib/libodbc.so.1
    #10 0xb70d3c9d in odbc_sqlconnect () from /usr/lib/php5/extensions/odbc.so
    #11 0xb70db4d4 in odbc_do_connect () from /usr/lib/php5/extensions/odbc.so
    #12 0xb70db6e5 in zif_odbc_connect () from /usr/lib/php5/extensions/odbc.so
    #13 0x081a743b in zend_get_user_opcode_handler ()
    #14 0x081a8839 in execute ()
    #15 0x0818bb49 in zend_execute_scripts ()
    #16 0x081516c2 in php_execute_script ()
    #17 0x0820309e in main ()

    Thanks

  4. #4
    Join Date
    Jun 2007
    Posts
    6
    Also, I have not upgraded to PSQL 9.50 because I am not unsure about maintaining data integrity. There is some accounting software using the DB, and I cannot upgrade and test.

    Thanks.

  5. #5
    Join Date
    Dec 2001
    Posts
    1,109
    Provided Answers: 4
    Dumb question, is Linux a requirement for the PHP? Because PHP runs on Windows, you might consider trying it on Windows.
    I have seen some problems with PSQL if it's prior to v9.5. I believe that PSQL links to older libraries but I don't have a Linux box to test and can't remember which ones.
    Mirtheil Software
    Certified Pervasive Developer
    Certified Pervasive Technician
    Custom Btrieve/VB development
    http://www.mirtheil.com
    I do not answer questions by email. Please post on the forum.

  6. #6
    Join Date
    Jun 2007
    Posts
    6
    No, Linux is not a requirement for PHP, but there are a large amount of external programs called from PHP that make a switch to Windows unfeasible.

    Perhaps an upgrade to v9.50 is in order.

    Thanks.

  7. #7
    Join Date
    Jun 2007
    Posts
    6
    Ok, I tried upgrading PSQL to version 9.50.077.002 on a test machine, but I still get the same core dump.

    Thanks.

  8. #8
    Join Date
    Nov 2007
    Posts
    3

    That worked for me but...

    Mirtheil

    That sample worked great for me but I get an error at the bottom when I run it from the browser:

    Error in my_thread_global_end(): 1 threads didn't exit

    It appears at the very bottom after the "Number of Fields: 10". Any ideas?

  9. #9
    Join Date
    Dec 2001
    Posts
    1,109
    Provided Answers: 4
    Haven't seen that error before. A quick Google search for "my_thread_global_end()" shows that this is a bug in MySQL. If you've got MySQL enabled in the PHP.INI, you might try disabling it to see if the error goes away.
    Mirtheil Software
    Certified Pervasive Developer
    Certified Pervasive Technician
    Custom Btrieve/VB development
    http://www.mirtheil.com
    I do not answer questions by email. Please post on the forum.

  10. #10
    Join Date
    Nov 2007
    Posts
    3

    MySQL Bug

    Mirtheil,

    Yes, that fix the error. I guess we just have to wait until PHP fixes the bug.

    Thanks for your assistance!


    Skeeter

  11. #11
    Join Date
    Dec 2001
    Posts
    1,109
    Provided Answers: 4
    Mirtheil Software
    Certified Pervasive Developer
    Certified Pervasive Technician
    Custom Btrieve/VB development
    http://www.mirtheil.com
    I do not answer questions by email. Please post on the forum.

  12. #12
    Join Date
    Nov 2007
    Posts
    3
    My installed version is 5.2.5 and if I understand correctly I need to replace my ddl with a previous version's dll, correct?

    Thanks!

    Frank

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •