SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict kevin_tremblay's Avatar
    Join Date
    Jul 2001
    Location
    Boston Area (North shore)
    Posts
    233
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php and ODBC connections

    Has anyone used php with odbc connection calls. If so could you guide me to some good references for this or give me some guidance on good practices to use.

    Like formatting and do's and don't. I have used php with Mysql but now my office wants to hook to another database and I can with the ODBC calls but I would like to get some formatting things worked in as well.

    Thanks for any help.

    Kevin -- Digitalman
    Kevin Tremblay-- Sys Admin
    work: kevin_tremblay@hsgmed.com
    "The object of the journey is not to arrive."

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I can't give you details right now as I'm not home (on a relative's laptop) but tomorrow I could.. I have the book "PHP Essentials", basically a beginner's PHP book, but it details how to interact with 10 or 12 different database types with PHP and I'm sure ODBC is in there.. Do you just need the general info? Maybe I could retype a few paragraphs of that for you tomorrow, email me if you want.. though I'm sure I'm not very helpful

  3. #3
    SitePoint Addict kevin_tremblay's Avatar
    Join Date
    Jul 2001
    Location
    Boston Area (North shore)
    Posts
    233
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, any help or guidance on this one would be great.

    Kevin -- Digitalman
    Kevin Tremblay-- Sys Admin
    work: kevin_tremblay@hsgmed.com
    "The object of the journey is not to arrive."

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    From "PHP Essentials":

    odbc_connect() Opens a connection to an ODBC datasource. Requires the datasource name, username, and password.

    odbc_prepare() Readies the SQL statement for execution.

    odbc_execute() Executes the SQL statement.

    odbc_result_all() Places the results of your SQL statement into a nicely-formatted HTML table.

    odbc_free_result() Frees the resources in use by the current connection.

    ocbc_close() Closes the current connection.
    And here are examples for using the above, also from the book:

    $connection = odbc_connect("DSN=secretDB","sandman","34Nhjp") or die ("Couldn't connect to the datasource.");

    $sql = "SELECT FULL_NAME FROM FRIEND_INFO";

    $sql_statement = odbc_prepare($connection,$sql) or die("Couldn't prepare statement.");

    $sql_result = odbc_execute($sql_statement) or die("Couldn't execute query.");

    If you'd like to see the results of $sql_result in a table, just use odbc_result_all($sql_result,"border=1");

    odbc_free_result($sql_result);
    odbc_close($connection);


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
  •