Connecting to a Access database using ODBC and no DNS

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Yew12
    New Member
    • Mar 2008
    • 23

    Connecting to a Access database using ODBC and no DNS

    Hi, I'm having problems connecting to a Microsoft Access database. Im using PHP and ODBC but im not using a DNS.

    The scripts below give no errors but I they only give me a blank white screen.

    Any would be greatly appresiated. Please help.

    Script 1
    [php]
    <HTML>
    <HEAD>
    <TITLE> Browse the race table </TITLE>
    </HEAD>
    <BODY>
    <?php
    $connstr = "DRIVER={Micros oft Access Driver(*.mdb)}; DBQ=".realpath( "Database/2PointB.mdb")." ;";
    $conn=odbc_conn ect($connstr,", ");
    $stmt=odbc_tabl es($conn);
    while( odbc_fetch_row( $stmt))
    {
    $tabletype = odbc_result($st mt,4);
    $tablename = odbc_result($st mt,3);
    if($tabletype =="TABLE")
    {
    Print "<a HREF=browserace .php?table=" .$tablename.">" .$tablename ."</a>";
    Print "<br>";
    {
    }
    ?>
    </BODY>
    </HTML>[/php]Script 2[php]
    <HTML>
    <HEAD>
    <TITLE> Browse </TITLE>
    </HEAD>
    <BODY>
    <?php
    $table=$_GET["table"];
    $sql="Select * from $table";
    $connstr = "DRIVER={Micros oft Access Driver(*.mdb)}; DBQ=".realpath( "Database/2PointB.mdb")." ;";
    $conn=odbc_conn ect($connstrr," ,");
    $stmt=odbc_exec ($conn,$sql);
    $nofileds=odbc_ num_fields($stm t);
    while( odbc_fetch_row( $stmt))
    {
    $i=1;
    while ($i<$nofields)
    {
    Print odbc_result($st mt,$i)."";
    $i==;
    }
    Print "<br>";
    }
    ?>
    </BODY>
    </HTML>[/php]
    Last edited by ronverdonk; Apr 12 '08, 10:56 PM. Reason: code tags corrrectly placed
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    You don't get an error, because you don't display any errors. Add an error display to each of the odbc_* command like[php]$conn=odbc_conn ect($connstr,", ")
    or die ("connect error: ".odbc_error()) ;
    $stmt=odbc_tabl es($conn)
    or die ("show table error: ".odbc_error()) ;[/php]and you'll get more information on your problem.

    Ronald

    Comment

    Working...