SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: php and ODBC

  1. #1
    SitePoint Addict
    Join Date
    Feb 2003
    Location
    durango
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php and ODBC

    Hi All,

    I think this is very basic but I can't seem to figure it out. I need to connect to an ODBC database and display the field values. I set up a testing script but can't seem to get it to work. I know I am connecting to the database because I can display the table names and column names. I just can't seem to display the values. I'm not getting any errors, it just shows no results. Can you see what I'm doing wrong?

    Code:
    <?php
    if (!$conn)
      {exit("Connection Failed: " . $conn);}
    $sql="SELECT wID, wName, wAccount, wAccountNo, wEmail, wCreated, wUpdated FROM cf_recommend ORDER BY wUpdated DESC";
    $rs=odbc_exec($conn,$sql);
    echo $sql;
    if (!$rs)
      {exit("Error in SQL");}
    echo "<table border=1><tr>";
    echo "<th>ID</th>";
    echo "<th>Contact name</th></tr>";
    while (odbc_fetch_row($rs))
      {
      $compname=odbc_result($rs,1);
      $conname=odbc_result($rs,2);
      echo "<tr><td>$compname</td>";
      echo "<td>$conname</td></tr>";
      }
    odbc_close($conn);
    echo "</table>";
    ?>
    If I only had a brain.

  2. #2
    SitePoint Addict
    Join Date
    Feb 2003
    Location
    durango
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i found the problem,

    thanks anyway...
    If I only had a brain.


Bookmarks

Posting Permissions

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