cant connect php to access via odbc over network

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yodboy
    New Member
    • Dec 2006
    • 1

    cant connect php to access via odbc over network

    hi there

    Im going nuts - any help appreciated

    trying to connect to access db over a network

    so far -
    I can connect to the db using the same odbc with excel
    I can connect to a copy of the db using a similar odbc on a local drive with php

    I just cant connect to it over the network - is this a permissions thing possibly??
    the error I get is:
    Warning: odbc_connect() [function.odbc-connect]: SQL error: , SQL state 00000 in SQLConnect

    code below:

    $testdb = odbc_connect('t estMWL', '','' );
    $sql2 = "select * from COMPANY";
    $rs2 = odbc_exec($test db,$sql2);
    if (!$rs2)die(odbc _error());

    while($data2 = odbc_fetch_arra y($rs2)){
    echo etc etc
    }


    thanks in advance
    yodboy
  • mainul
    New Member
    • Sep 2006
    • 51

    #2
    save the file as odbc.php

    [PHP]<? $odbc = odbc_connect ('dbname','dbus ername,' 'dbpass' ) or die('Could Not Connect to ODBC Database!');
    if (function_exist s(odbc_fetch_ar ray))
    return; ?>
    [/PHP]

    insert.php file

    [PHP]
    <?
    include('odbc.p hp');
    $qryStr = "INSERT INTO table_name(.... ..) VALUES(.....);
    odbc_exec($odbc , $qryStr)or die (odbc_errormsg( ));
    odbc_close($odb c);
    ?>
    [/PHP]

    Comment

    • mainul
      New Member
      • Sep 2006
      • 51

      #3
      Originally posted by mainul
      save the file as odbc.php

      [PHP]<? $odbc = odbc_connect ('dbname','dbus ername,' 'dbpass' ) or die('Could Not Connect to ODBC Database!');
      if (function_exist s(odbc_fetch_ar ray))
      return; ?>
      [/PHP]

      insert.php file

      [PHP]
      <?
      include('odbc.p hp');
      $qryStr = "INSERT INTO table_name(.... ..) VALUES(.....);
      odbc_exec($odbc , $qryStr)or die (odbc_errormsg( ));
      odbc_close($odb c);
      ?>
      [/PHP]

      sorry i left few codes

      [PHP]
      <?
      include("odbc.p hp");
      $sql="SELECT * FROM table_name";
      $result=odbc_ex ec($odbc,$sql);

      //echo "<TABLE border=1 align = 'center'>";

      //echo"<TR bgcolor = '#999999'><TD>< B>Heading1</B><td>Heading2 </td></TR>";
      while ($myrow = odbc_fetch_arra y($result))
      {
      //echo "<TR><TD>";
      echo $myrow["feild_name 1"];
      //echo"<td>";
      echo "$nbsp $nbsp $nbsp";
      echo $myrow["feild_name 2"];
      //echo "</tr>";


      }
      //echo "</TABLE>";
      ?>
      [/PHP]

      Comment

      Working...