Jump to content

PEAR DB Install help


c19h28o2

Recommended Posts

Hi,

I've installed pear via pear install db and appears to have installed correctly, however i'm going through Learning PHP and MySQL, the below code should use pear db but it does not work.  I"m running php5 on osx I don't receive an error the page is blank when its run.  mysql and php is setup correctly as it scripts run fine without db.

This is the code....

[code]
<?php
include('db_login.php');
require_once( 'DB.php' );
$connection = DB::connect( "mysql://$db_username:$db_password@$db_host/$db_database");
if (!$connection)
{
  die ("Could not connect to the database: <br>". DB::errorMessage());
};
$query = '
CREATE TABLE `purchases` (
  `purchase_id` int(11) NOT NULL auto_increment,
  `user_id` varchar(10) NOT NULL,
  `title_id` int(11) NOT NULL,
  `purchased` timestamp NOT NULL,
  PRIMARY KEY  (`purchase_id`)
)
';
echo ("Table created successfully!");
$result = $connection->query($query);
if (DB::isError($result))
{
  die ("Could not query the database: <br>". $query. " ".DB::errorMessage($result));
}
$connection->disconnect();
?>
[/code]

Thanks for your help
Link to comment
https://forums.phpfreaks.com/topic/35089-pear-db-install-help/
Share on other sites

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.