Jump to content

Pear Installation and Database


dkoolgeek

Recommended Posts

I am creating a website for a school project.

When I attepmt to run the following code, I get an error.
I think it may have something to do with pear but I am not sure.

<?php

require_once 'DB.php';


$db_engine = 'mysql';
$db_user = 'username';
$db_pass = 'password';
$db_host = 'localhost';
$db_name = 'database';

$datasource = $db_engine.'://'.
  $db_user.':'.
  $db_pass.'@'.
  $db_host.'/'.
    $db_name;


$db_object = DB::connect($datasource, TRUE);

/* assign database object in $db_object,

if the connection fails $db_object will contain

the error message. */

// If $db_object contains an error:

// error and exit.

if(DB::isError($db_object)) {
die($db_object->getMessage());
}

$db_object->setFetchMode(DB_FETCHMODE_ASSOC);

// we write this later on, ignore for now.

include('check_login.php');

?>
Link to comment
https://forums.phpfreaks.com/topic/29345-pear-installation-and-database/
Share on other sites

What is the error code? And also instead of DB you should use MDB2. it's like an newer version of DB and it's recommended. If the error is something about DB:Error then you should check the validity of your connection string. Try echoing it and look if anything is wrong

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.