PEAR Problem

software development

#1

Hi,

I’m a complete and utter noob to PEAR but I decided to learn it so I can seperate the presentation of my websites from the PHP coding.

I purchased the book Web Database Applications with PHP and MYSQL which disucces the use of PHP and PEAR in some depth with a sample project at the end.

Now this sample project can be downloaded from www.webdatabasebook.com and installed/upload to follow the code etc.

However I have received a series of PEAR errors which I have no idea how to solve. I have searched around the internet for a solution and haven’t really understood any or not found one.

Errors I’m receiving vary from

Non-static method DB::connect() should not be called statically

to

Non-static method DB::parseDSN() should not be called statically

to

var: Deprecated. Please use the public/private/protected modifiers

Has anyone else bought this book and had these problems or know how to solve them I’m really stuck with no idea how to fix it.

Please help!


#2

Firstly, are you running your website under PHP4 or PHP5? You can check from 'Manage Domains [edit]'
The location for the PEAR packages are in different locations for the two PHPae.

If you switch to PHP4 using ‘Manage Domains [edit]’ you should get the application to use db.php okay but you may run into another PEAR problem because the PEAR templates module is not loaded.

See the wiki entry for PEAR to see how to set up your own local PEAR additional modules. You will find it best to use SSH to install the modules required such as

pear install -o HTML_Template_IT

(when you run the winestore application you may see error messages referring to any missing PEAR modules which are installed as above )

The winestore application in the book is I think aimed at being installed on your own PC/Server rather than a shared server. Some changes need to be made to install the winestore database and path changes in the winestore.inc file especially the error.log file which is ccurrently pointing to /tmp rather than $home/tmp

See how you do with that for now.

If you install a local PEAR you can try switching back to PHP5 and using it.

Presumably you have the second edition of the book and are using the second edition files?

It is too hot to continue and my dog has eaten my dinner!


Norm

Opinions are my own views, not DreamHosts’.
I am NOT a DreamHost employee OK!! :@

You act on my advice at your own risk!


#3

I am running PHP5. I switched it to PHP4 like you said but the page just comes up as blank and doesn’t display anything.

I have already installed all the templates needed IT and ITX aswell as the DB module.

And yes I am using the second edition of the book which means the application should work fine on PHP5 but it isn’t.


#4

I have it running under PHP4.
I made so many changes to get it to work under 5 that I do not know what I have changed.

I believe you can probably do without a Local Pear under PHP4. The errors you were seeing are due to changes since PHP4.

If you can give me 30 minutes or so I can go through the .inc files to see what I changed.
From scribbled notes it was just setting the DB entries in db.inc and changing a path or two in winestore.inc.


Norm

Opinions are my own views, not DreamHosts’.
I am NOT a DreamHost employee OK!! :@

You act on my advice at your own risk!


#5

Right then.
Use PHP4

Create the database winestore with a hostname,user,userpass as usual from DH ControlPanel.
Edit the winstore database file from the ZIP called winstore.data and comment out the first three lines

drop database if exists winestore;
create database winestore;
use winestore;

to

#drop database if exists winestore;
#create database winestore;
#use winestore;

Resave winestore.data to say winestore.sql (I do not know if it would have worked with those lines left in probably would)

Log into the database winestore using PHPMyAdmin and select the database and use the import button and import winestore.sql from the PC to set up the tables and entries.

That completes the DB side.

Install the wda2-winestore folders and files from the PC to DreamHost under a folder name called wda2-winestore.

i.e. at /home/user/example.com/wda2-winestore

Now go to the includes folder and edit db.inc to show details of database name,hostname,user,userpass.

edit winestore.inc

set define(“D_INSTALL_PATH”,

to

define(“D_INSTALL_PATH”, “/home/username/example.com”);

set define(“D_WEB_PATH”,

to

define(“D_WEB_PATH”, “/wda2-winestore/”);

(default I think)

Scroll down a bit and set the location of the error log

define(“ERROR_FILE”, “/home/user/example.com/wda2-winestore/tmp/php_error_log”);

and create that ‘tmp’ folder under wda2-winestore.

Now the tricky bit. I cheated here because I should have set up the local PEAR pathnames I suppose.

Copy the three files from your local PEAR/php folder called IT.php, IT_Error.php,ITX.php to your wda2-winstore includes folder. Open each file in turn and check that the require_once lines near the top of each file only contains a filename and not the path to the local PEAR folder where they once lived.

I think that should do it.

Run http://example.com/wda2-winstore/

That should give the index and clicking ‘use the application’ should…

It is a bit of a hodge podge but it gets the thing going. Something may break further along most likely.
Hopefully the authors will update it for PHP5
Even more hopefully somebody will rewrite the PEAR wiki to make it easier to use the environment settings!


Norm

Opinions are my own views, not DreamHosts’.
I am NOT a DreamHost employee OK!! :@

You act on my advice at your own risk!


#6

Further, I found the three IT PEAR files had to copied into the order folder and order-step4.php had to be edited to remove the hard wired PEAR path for the ITX file.

The emailed receipts for the wine purchased seem to work okay.

Prices per bottle, from the search screen, are not displaying properly and only show the cents. Unless wine costs 66 cents a bottle?


Norm

Opinions are my own views, not DreamHosts’.
I am NOT a DreamHost employee OK!! :@

You act on my advice at your own risk!


#7

If you would please I really would like to get it working on PHP5 so I can use it as the basis to my own project running on PHP5.

Sorry to be such a bother but you help is throughly appreciated.


#8

I think it would need a rewrite of the code (by the authors) and I am only on page 7 :slight_smile:


Norm

Opinions are my own views, not DreamHosts’.
I am NOT a DreamHost employee OK!! :@

You act on my advice at your own risk!