odbc_error() questions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Wescotte

    odbc_error() questions

    Reading the docs I noticed the following appended by a user

    "If you use an argument, make sure its the CONNECTION_ID and not the
    RESULT_ID.
    Testing the result can return a null string or sometimes a garbage
    string."

    I'm getting very strange results when using odbc_error($con nect) where
    it's almost always true and when I follow up with
    odbc_errormsg($ connect); I get junk results. However if I leave out a
    connection id it seems to function correctly (that is never returns
    true)

    Any ideas why I'm sometimes getting garbage back?

    Here is a little sample I wrote with it's output

    <?php

    include "c:/out_of_httpd_sc ope_vars.php";
    $connect = odbc_connect ("AS400", $USERNAME,$PASS WORD);
    odbc_autocommit ($connect, FALSE);

    if ($connect == false)
    printf("Problem connecting to the database");

    for ($i = 1; $i < 1000; $i++) {
    $query = "LOCK TABLE WEBSYS.FRTBNUM IN EXCLUSIVE MODE";
    $result = odbc_exec($conn ect, $query);
    if (odbc_error($co nnect)) {
    echo "ERROR! Unable to lock table SQL ($query) failed errormsg = (" .
    odbc_errormsg($ connect) . ") <BR>";
    }
    odbc_rollback($ connect);

    }
    odbc_close($con nect);
    ?>

    Output is 1000x of
    ERROR! Unable to lock table SQL (LOCK TABLE WEBSYS.FRTBNUM IN EXCLUSIVE
    MODE) failed errormsg = ()


    However when I don't put this in a loop and just execute it a single
    time sometimes it outputs the error message and sometimes it doesn't.

    So do I just drop the $connect from odbc_error()?

Working...