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

    Join Date
    Apr 2013
    Posts
    3
    Rep Power
    0

    Help with Non-DSN Connection


    PHP Code:
    <?php
    //create an ADO connection and open the database
    $conn = new COM("ADODB.Connection");
    $conn->open("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\sd_tbf.mdb");

    //execute an SQL statement and return a recordset
    $sql "SELECT LastName, FirstName, Email, Phone FROM Employees"
    $rs $conn->execute($sql);
    $num_columns $rs->Fields->Count();

    echo 
    "<table border='1'>";
    echo 
    "<tr><th>Last Name</th><th>First Name</th><th>Email</th><th>Phone</th></tr>";
    while (!
    $rs->EOF//looping through the recordset (until End Of File)
    {
    echo 
    "<tr>";
    for (
    $i=0$i $num_columns$i++) {
    echo 
    "<td>" $rs->Fields($i)->value "</td>";
    }
    echo 
    "</tr>";
    $rs->MoveNext();
    }
    echo 
    "</table>";

    //close the recordset and the database connection
    $rs->Close();
    $rs null;
    $conn->Close();
    $conn null;
    ?>
    Folks, I am trying to connect to a local MS Access db to display a simple table - I seem to be failing on the connection piece, and I wonder if you guys can see the syntax error?

    I am a relative noob to php, and this is for a course I am taking. I am using CSE HTML Validator Lite to write the code if that makes any difference.
  2. #2
  3. No Profile Picture
    I haz teh codez!
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2003
    Posts
    2,555
    Rep Power
    2338
    Try

    PHP Code:
    $conn->open("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\sd_tbf.mdb"); 
    Failing that, you could tell us what the error is, exactly.
    I ♥ ManiacDan & requinix

    This is a sig, and not necessarily a comment on the OP:
    Please don't be a help vampire!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    3
    Rep Power
    0
    Originally Posted by ptr2void
    Try

    PHP Code:
    $conn->open("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\sd_tbf.mdb"); 
    Failing that, you could tell us what the error is, exactly.
    I am still getting the same issue - it fails just before open, so that open("PROV .. . ) is all displayed as if it were html text.

    I am trying to upload a screenshot so you can see what I get when I run it.
  6. #4
  7. No Profile Picture
    I haz teh codez!
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2003
    Posts
    2,555
    Rep Power
    2338
    Does your file have a .php extension?
    I ♥ ManiacDan & requinix

    This is a sig, and not necessarily a comment on the OP:
    Please don't be a help vampire!
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    3
    Rep Power
    0
    Originally Posted by ptr2void
    Does your file have a .php extension?
    It does, yes. proj1index.php.

    here's the link to the page - it looks like the server isnt configured properly to handle ADO requests.

    Well, since i'm new, can't post the URL

    www2 <dot> esc<dot>edu <slash> sdolan <slash> proj1index.php

    Sean
  10. #6
  11. No Profile Picture
    I haz teh codez!
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2003
    Posts
    2,555
    Rep Power
    2338
    According to the error on that page,
    Provider cannot be found. It may not be properly installed
    perhaps maybe one of the links in this Google search might help.
    I ♥ ManiacDan & requinix

    This is a sig, and not necessarily a comment on the OP:
    Please don't be a help vampire!

IMN logo majestic logo threadwatch logo seochat tools logo