Jump to content

Php with MsAccess


jeeva

Recommended Posts

Is there any major difference between mysql and Ms Access  to be used with php?

 

Not really, but it depends what you mean. You use the odbc] interface to connect to access. It has much of the same functionality as the mysql* interfaces. Access's sql is a little different in places as well but this has nothing really to do with php.

Link to comment
Share on other sites

mysql

<?php
$con =  mysql_connect("server","username","password");
mysql_select_db("database");
mysql_query("SELECT * FROM items");
?>

 

ms access(only on MS Windows server does not mater)

 

<?php
$con = new COM("ADODB.Connection");
// MS Access 2003 or before
$db = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("./db.mdb").";";

// MS Access 2007
//$db = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=". realpath("./db.accdb").";";

$db_conn->open($db);
$rS = $db_conn->execute("SELECT * FROM items");
$f1 =  $rS->Fields(1);
$f2 =  $rS->Fields(2);
$f3 =  $rS->Fields(3);
$f4 =  $rS->Fields(4);
$f5 =  $rS->Fields(5);
$f6 =  $rS->Fields(6);
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.