odbc_exec example request

Discussion in 'PHP' started by omnii, Jun 13, 2007.

  1. #1
    /*This script connects to a remote database ok, though I have been unsuccessful in retrieving any data using odbc_exec, either because of incorrect syntax, or I just have no clue what I am doing, or both.

    There is a remote database I just want to retreive data from at this point and then return the results to a webpage.

    Any help would be much appreciated so this newbie can get started and do more interesting things with the data later.
    */


    <?php


    $conn = odbc_connect('xyz.abc.com','login','password');

    if ($conn <=0) {
    echo "Error in connection<BR>";
    exit;
    }
    else {
    echo "<P>Connection successful\n";
    };

    {

    $query = 'SELECT * from XYZ_ITEM where ITEM = 'wrench');

    $result = odbc_exec($conn, $query);

    echo $result;

    }
    ?>
     
    omnii, Jun 13, 2007 IP
  2. omnii

    omnii Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I have looked at lots of examples of pulling data from MS Access databases, but that is not what I need, the database is SQL Server that I want to pull data from.

    I have tried using odbc_fetch_row, but I haven't been able to retrieve data yet, the page just comes up blank whenever I put in code other than that which is used to connect to the database.

    Do I need to use <tr> and <td> to be able to display data in the first place? I could really use some guidance on how to get started retrieving and displaying data from this database.
     
    omnii, Jun 14, 2007 IP