#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2011
    Posts
    12
    Rep Power
    0

    Problems with DB2


    I only have two months with PHP. I am trying to access a DB database with ODBC but I have a problem and haven't found the solution in the Internet. My code is:

    Code:
    $dbconn = odbc_connect("xxx", "xxx", "xxx");
    $statement = odbc_prepare ($dbconn, $sql);
    $result = odbc_exec($dbconn, $statement);
    I get the connection and the statement, but I get an exception getting the result.

    If you can give me code to execute a select statement, that would help me too. I haven't been able to do it with what i have searched and i settled for ODBC>

    Your help would be greatly appreciated.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2011
    Posts
    12
    Rep Power
    0

    Another way it fails


    [QUOTE=handro1104]I only have two months with PHP. I am This code fails too:

    Code:
    $dbconn = odbc_connect("xxx", "xxx", "xxx");
    $result = odbc_exec($dbconn, $sql);
    The sql works fine with DbVisualizer.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2011
    Posts
    12
    Rep Power
    0
    The actual problem is that I am getting false for $result.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2011
    Posts
    12
    Rep Power
    0

    Solved


    $dbconn = odbc_connect("xxxx", "xxxx", "xxxx");
    $sql ="select name, local_name from factory.attachments where name like '%7142930%UNCLASSIFIED.xml' FETCH FIRST 2 ROWS ONLY;";
    $result = odbc_exec($dbconn, $sql);
    while (odbc_fetch_row($result)) {
    $fileName = odbc_result($result, 'Name');
    echo "$fileName<br/>";
    }

IMN logo majestic logo threadwatch logo seochat tools logo