DB Newbie question.

From: Date: Thu, 22 Sep 2005 18:04:31 +0000
Subject: DB Newbie question.
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-21084@lists.php.net to get a copy of this message
I've: Windows XP + Apache 1.3.28 + PHP 4.3.3 + PEAR + MS Access 2000 + MDAC 2.8 PC All working perfectly, but when I try to connect to ACCESS throug DB PEAR, I get an error: Standard Message: DB Error: connect failed Standard Code: -24 DBMS/User Message: [nativecode=IM002 [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified] ** Array DBMS/Debug Message: [nativecode=IM002 [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified] ** Array BUT, when I not use PEAR DB , works! This can't connect: <?php // PEAR DB VERSION error_reporting(E_ALL); require_once 'DB.php'; $dsn=array( 'phptype' => 'odbc', 'dbsyntax' => 'access', // 'protocol' => false, 'hostspec' => '127.0.0.1', 'database' => 'TestDB', 'username' => '', 'password' => '' // 'proto_opts' => false, // 'option' =>false ); $options = array( 'debug' => 5 ); $db =& DB::connect($dsn, $options); if (PEAR::isError($db)) { echo 'Standard Message: ' . $db->getMessage() . "\n"; echo 'Standard Code: ' . $db->getCode() . "\n"; echo 'DBMS/User Message: ' . $db->getUserInfo() . "\n"; echo 'DBMS/Debug Message: ' . $db->getDebugInfo() . "\n"; exit; } die("ok"); ?> how ever this non PEAR script WORKS !! ( script from phpfreaks tutorial) <?php error_reporting(E_ALL); $odbc = odbc_connect ('TestDB', '', '') or die('Could Not Connect to ODBC Database!'); if(!function_exists('odbc_fetch_array')) { function odbc_fetch_array($result, $rownumber=-1) { if (PHP_VERSION > '4.1') { if ($rownumber < 0) { odbc_fetch_into($result, $rs); } else { odbc_fetch_into($result, $rs, $rownumber); } } else { odbc_fetch_into($result, $rownumber, $rs); } $rs_assoc = Array(); foreach ($rs as $key => $value) { $rs_assoc[odbc_field_name($result, $key+1)] = $value; } return $rs_assoc; } } $query = odbc_exec($odbc, "SELECT * FROM Tabla1") or die (odbc_errormsg()); while($row = odbc_fetch_array($query)) { echo 'ID: '.$row['id'].'<br />'; echo 'Nombre: '.$row['nombre'].'<br />'; echo 'Apellido: '.$row['apellido'].'<br />'; echo '<hr />'; } odbc_close($odbc); ?> Anybody can help me ? I want to run a PEAR DB powered script. Thank you in advance. andres.

« previous php.pear.general (#21084) next »