PEAR DB problem
Posted: Tue Jun 01, 2004 1:48 am
Hi,
I am trying to use PEARs abstraction layer and i have this code:
Can someone please tell me why i get nothing??
Even if i change mysql string to mssql (mssql does not exist on my system) i don't get a message. I only get an error when i change mysql to smysql or something.
I am trying to use PEARs abstraction layer and i have this code:
Code: Select all
<?php
//The database configuration file
//It connects the user to the DB
//Your SQL type
$dbase= 'MySQL';
//Your bduser string
$user = 'root';
//Your db pass
$pass = 'root';
//Your db host
$host = 'localhost';
//Your DB name
$db_name = 'zeuscms_02';
//This is the string that will be used for the connection
$dsn = '$dbase://$user:$pass@$host/$db_name';
//Require the Abstraction layer
require_once "dblayer/DB.php";
//Connect to the database
$db = DB::connect("$dbase://$user:$pass@$host/$db_name");
//If there is an error warn the user
if (DB::isError($db))
{
die ($db->getMessage());
}
$sql = "select * from news";
$demoResult = $db->query($sql);
while ($demoRow = $demoResult->fetchRow(DB_FETCHMODE_ASSOC)) {
echo $demoRow['headline'] . '<br>';
}
?>Even if i change mysql string to mssql (mssql does not exist on my system) i don't get a message. I only get an error when i change mysql to smysql or something.