Hi folks!

I want to ask you something:
Is there a way to access the Microsoft Access(I think) .mdb files from PHP like some server or data source as it's done in the ASP?

Alternative:
Is there any way to create databases without using any SQL server(I mean something like MDB or so.)

    Use ODBC. Set up a system DSN on the server and connect via that. I've only got it to work when the mdb file is on the same machine as the web server.

    Check out the php manual for odbc functions. eg:-

    $cnxn = odbc_connect ("dsnname","usr","pwd");

    $result = odbc_exec($cnxn,"select * from tablename");

    hth

      9 days later

      Hi there!

      Thanks for the answer bu it will be more easy for me to understand it if you apply any active code(a part of a php page or so).

      Also how do I disconnect the mdb?

      TIA,
      Djum@ka.

        Here's a sample from one of my apps:-

        function getcontracts() {
        	global $cnx;
        	$sql = "SELECT contract.contract_id, contract.enddate, Operator.OperatorName, route.rtedesc ".
        	"FROM (Operator INNER JOIN contract ON Operator.op_id = contract.op_id) ".
        	"INNER JOIN route ON route.rte_id = contract.rte_id ".
        	"order by contract.enddate ";
        	$Q = odbc_exec($cnx,$sql);
        	$res = "";
        	while (odbc_fetch_into($Q,$array)) {
        		list($contract,$exp,$op,$rte)=$array;
        		$days = daysLeft($exp);
        		$class = ($days<90)?"class=\"renew\"":"";
        		$res .= "<tr><td class=\"con\">$contract</td><td>$op</td><td>$rte</td><td $class> ".formDate($exp)."</td>";
        	}
        	odbc_free_result($Q);
        	odbc_close($cnx); /*disconnect*/
        	return $res;
        }
        
        

        hth

          5 days later

          Ok the example is good but what do I need to write in that ODBC_Connect and its fields to make it work. For example the files is messages.mdb and is in the same directory as the php script.

          Sorry for troubling you again

          Thank's for all!
          Djumaka

            As I said in my post of Nov 13

            $cnx = odbc_connect("DSNname", "username", "password");

            where DSNname is the the name you gave to your ODBC DSN via control panel.

            If you have no system.mda file, you only need

            $cnx = odbc_connect("DSNname", "", "");

            hth

              I'm using a free hosting and the did not give me any DSN so what do I need to know so that I can menage that. In ASP it is easy - the ADO is called to access the .mdb file.

                Write a Reply...