DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

PHP : Conectar Con Access / Connect With Access

07.23.2007
| 6598 views |
  • submit to reddit
        Conectar con Access / Connect with Access.
Código fuente / Source code :

$pathDB = str_replace("/", "\\", $_SERVER["DOCUMENT_ROOT"]) . "\\directory1\\directory2\\bdd.mdb";

if(!file_exists($pathDB))
{
echo "!!! Base de datos no encontrada ".$pathDB;
exit;
}

$conexion = odbc_connect("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=".$pathDB, "ADODB.Connection", "", "SQL_CUR_USE_ODBC");
$sql="select * from tabla where 1";
$resultado=odbc_exec($conexion,$sql);
if($resultado)
{
	while($fila=odbc_fetch_array($resultado))
	{
	echo $fila['campo1']."<br />";
	echo $fila['campo2']."<br />";
	}
odbc_close_all();
}