MikeMikeMike Posted April 23, 2011 Share Posted April 23, 2011 Hi, Update: If you look at my first reply to this OP (which is the third post overall), it has the current status of the problem. Namely, I can get a test file to work (suggested by the Pear website) but not the login.php file from the Chapter 4 scripts. The details in this OP are probably not relevant anymore but I didn't want to erase them because I wasn't sure on forum rules. Nevertheless, please focus attention on the 3rd overall post if you can help. I'm not sure if the problem I'm having with Chapter 4 login.php is related to the unsolved problem I've had installing Pear (see my other question in this forum about installing pear on a Mac with MAMP). When I'm running login.php from chapter 4 I'm getting a server error. Besides the pear installation problem, here's what I did Since I was able to download the Pear files (at least some of them), I just plopped auth.php (which login.php requires) into the same directory as the scripts for chapter 4, like this Is that wrong? Moving on, Larry says that login.php /* This page uses PEAR Auth to control access. * This assumes a database called "auth", * accessible to a MySQL user of "username@localhost" * with a password of "password". * Table definition: I created the database and table etc. Larry says the database must be accessible to a MySQL user of "username@localhost" with a password of "password" so in the script he has this code $options = array('dsn' => 'mysql://username:password@localhost/auth'); But since my MySQL username is root and my password is root, I changed his code to $options = array('dsn' => 'mysql://root:root@localhost/auth'); but as mentioned I'm getting a server error. Anyone have any ideas? Is it because I'm not doing something right with Pear? or this code? I'm on a Mac 10.6.6. with MAMP installed. Actually, I just looked at Auth.php and saw that it requires other fils, and those files require other files, so I think this has to do with installing Pear properly so that the book files have access to the Pear files All of the pear files are burried in the bin folder (see below), while my files downloaded from Larry's book are in htdocs. What's the best way to set this up? Do I just copy the files into the same folder? Link to comment Share on other sites More sharing options...
Jonathon Posted April 23, 2011 Share Posted April 23, 2011 from my experience with pear I broke my installer so modules didn't install but they downloaded ok. I tried what your doing and I couldn't get it to work, you only have to miss a file or it be referenced wrongly in some includes and it won't work. So until you've installed pear and its all good. I be cautious about trying to do the examples. What is the error saying? Link to comment Share on other sites More sharing options...
MikeMikeMike Posted April 23, 2011 Author Share Posted April 23, 2011 Taking a tip from the pear website, I created a test file to check the installation of Pear, and it worked. This was the code in the test file, which was in the same directory as login.php for Chapter 4 files. <?php require_once 'System.php'; var_dump(class_exists('System', false)); ?> However, when I try to run login.php, I'm getting the following error now (i.e. no longer a server error, rather seems more of a path error) Warning: require_once(Auth.php) [function.require-once]: failed to open stream: No such file or directory in /Applications/MAMP/htdocs/phpvqp2_scripts/Ch04/login.php on line 19 Fatal error: require_once() [function.require]: Failed opening required 'Auth.php' (include_path='.:/Applications/MAMP/bin/php5.3/lib/php') in /Applications/MAMP/htdocs/phpvqp2_scripts/Ch04/login.php on line 19 So that's that problem. I also note that because my username and password are both "root", I changed this line $options = array('dsn' => 'mysql://root:root@localhost/auth'); but I don't know if this could be the problem... Link to comment Share on other sites More sharing options...
Jonathon Posted April 23, 2011 Share Posted April 23, 2011 Yeah it seems to be that at the very least your not referencing the path to 'Auth.php'. Try searching for it and working out the right path. But be warned that as I said I had a very similar problem later on in the book after I broke my installer. I did put the right paths in, but this subsequently meant other errors occured because of the files/classes referenced inside the file i'd moved. I don't envy you 1 Link to comment Share on other sites More sharing options...
Recommended Posts