Status
Not open for further replies.

Joseph Grogan

New Member
Hi everyone....


I bought a book about php and mysql. Its an O'reilly one......

Its good but there is this one part where instead of using this to connect to a database

PHP:
include('dbLogin.php');
// Connect
$connection = mysql_connect( $db_host, $db_username, $db_password );
if (!$connection)
{
   die ("Could not connect to the database: <br />". mysql_error());
}
// Select the database
$db_select=mysql_select_db($db_database);
if (!$db_select)
{
   die ("Could not select the database: <br />". mysql_error());
}


its using this

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()); };

So when i try us this i am getting back this in the browser

Fatal error: Class 'DB' not found in ...........

Any ideas from anyone
 

Forbairt

Teaching / Designing / Developing
have you actually installed pear ? and the required DB class ? :)

If yes ... then are the paths correct ?
 

Joseph Grogan

New Member
I think that is where the problem lies... I dont know anything about pear or how to install it on a shared hosting account so i a bit confused
 

Forbairt

Teaching / Designing / Developing
This is ripped from
PHP PEAR - DreamHost Forum

but it should be pretty much the same ... hopefully ?
failing that set it up locally and copy the PEAR directory onto your shared host and link to it ( add it to your php path )

Hope that helps ... there'll be tinkering involved :)


1. Create a directory to install PEAR: e.g. ~/php.

2. Run "lynx -source http://go-pear.org | php" in this directory.

3. During the installation, change the directories to match your configuration. PEAR will create directories as appropriate. Don't forget to change PEAR's bin directory to something you can write to, e.g.: ~/bin.

4. PEAR should then download all the sources and configure itself using the directories provided above.

5. Run "~/bin/pear config-show" to see the configuration of your new PEAR installation. Ensure these directories are writable and readable by your user and apache. Use "~/bin/pear config-set setting value" to modify these settings to your ~/php PEAR installation.

6. Add the "~/bin/pear" binary to your path. If your shell is BASH, type "export ~/bin:$PATH". Don't forget to add this to your .bash_profile, using "echo PATH=~/bin:$PATH >> ~/.bash_profile"!

7. Simply add "php_value include_path ".:/home/username/php"" to an htaccess file telling PHP to use your new PEAR installation.
 

Forbairt

Teaching / Designing / Developing
Alternatively could I just recommend you download yourself a copy of wampserver ... and install and tinker locally with it ... it should mostly work the same apart from some crypt algorithm stuff ...
 

Joseph Grogan

New Member
Quick question

Just a quick question..... I am using MDB2 now instead of DB but i cant figure out how to install a pear packages. I have searched the internet everywhere. I know you have to type --pear install MDB2--

But i have no idea where to type that. No place says.. And when i open the MDB2 files in a browser nothing happens.

Bit confused:D
 

Forbairt

Teaching / Designing / Developing
is this on your localhost with wampserver or similar or on your shared hosting ?
 

Forbairt

Teaching / Designing / Developing
Your currently installed packages ...
pear list

List All available packages that you cna get
pear list-all

Install the package XYZ taking the name from the list we got with the last command ?
pear install packageNameHere


Hopefully thats some help ?
 

Joseph Grogan

New Member
Yea it does but the problem i having is i dont know where to type that..... I probably sound stupid cause it probably simple. But all i did was upload the files to my shared hosting and dont know what to do after that to install it......
 

Forbairt

Teaching / Designing / Developing
damn .. sorry .. here I'm slightly lost ... I do by playing a lot of the time and I've not been playing with pear on shared hosting ...

What I ended up doing before due to restrictions on what I was able to do was to upload the files and then just change the includes via .htaccess file to add in

php_value include_path .:/home/forbairt/pear

and hey presto things worked ... (or something like that)
 

Forbairt

Teaching / Designing / Developing
No problem ... probably won't get a chance to look into it more as I'm up to my neck at the moment.

so its over to someone else I think or trial and error
 
Status
Not open for further replies.
Top