Page 1 of 1

PEAR DB problem

Posted: Tue Jun 01, 2004 1:48 am
by basdog22
Hi,
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>';
    }
?>
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.

Posted: Tue Jun 01, 2004 2:28 am
by markl999
$dbase= 'MySQL'; needs to be$dbase= 'mysql';

Or at least it does on my system anyway ;)

Posted: Tue Jun 01, 2004 2:41 am
by basdog22
already done that. I was playing with it and made it MySQL to test :?

Nothing happens even if i change it to mosql 8O

anything wrong with my mysql installation??? Regular connect goes ok
eg:

Code: Select all

<?php
$dbhost="localhost";
$dbuser="root";
$dbpass="root";
$dbname="zeuscms_02";
//Connect to the database//
$connect = mysql_connect($dbhost, $dbuser, $dbpass, $dbname)or die(mysql_error());
mysql_select_db($dbname, $connect)or die(mysql_error());
$query=mysql_query("select * from news");
while($row=mysql_fetch_array($query))
{
	$i=$row['headline'];
	echo $i;
}
?>
works fine .

Posted: Tue Jun 01, 2004 2:57 am
by markl999
Can't see anything else obviously wrong.
Try putting error_reporting(E_ALL); as the first line of the script (after <?php) and see if there's any errors/warnings you're not seeing.

Posted: Tue Jun 01, 2004 4:39 am
by basdog22
No error, no warning... :x

I think i dl the class again :roll:

maybe another version

Posted: Tue Jun 01, 2004 4:59 am
by feyd
might need/want ini_set('display_errors','1') too...