views:

92

answers:

1

My php can't find mail.php

I installed the PEAR package in a directory named pear_admin I secured everything in that directory with .htaccess and .htpasswd When I go to mysite.com/pear_admin/index.php it asks for my username and password. This works and I am able to see and use PEAR Package Management I installed the Mail package. I created a php5.ini file and placed it in my root folder. When I click the submit button on my contact page, the PHP file finds php5.ini But then it goes wrong.

It can't find mail.php It's in the newly created directory. Which is different from where my Contact page is. php5.ini should solve that problem. The path in php5.ini is include_path = .:/usr/local/php5/lib/php:/home/content/91/5799191/html/mywebsite/pear_admin/PEAR

I tried quotes as well include_path = ".:/usr/local/php5/lib/php:/home/content/91/5799191/html/mywebsite/pear_admin/PEAR"

I'm not sure if there're any other solutions I need to try. I don't think I did anything wrong when I installed the Mail package. It's just a click of a button.

Maybe it's the PHP I tried both require_once "Mail.php"; and include('Mail.php');

Maybe it's because I secured it with .htpasswd That's something I don't understand. How can it access that file when I'm not giving it the username and password in my PHP? Shouldn't I be doing that? If so, how ?

Thank you.

A: 

You're confusing yourself over how .htpasswd protection works. PHP's already executing on the server, and does NOT go through the webserver to include external files. It can just access them directly - after all, they're on the same machine.

Of course, if you were using something that DOES do an http request (CURL, file_get_contents with an absolute url, etc...) then those WILL go via the webserver and be affected by the password protection.

You sayd you're doing include('Mail.php'), but say you installed mail.php. Remember that Unix-based servers have case-sensitive file systems, and Mail.php is a completely different file than mail.php. The same goes for your include path. If you install something in /tmp/FOO but attempt to access it via /tmp/foo, it won't work.

Marc B
I'm using a relative url, but it's in a different directory. Not a subdirectory. If I understand it right then that shouldn't make a difference, is that correct?
Kris
You're right about those 2 files being different. My mistake. I installed the Mail package and what I need is Mail.php . There's also a mail.php file but that's not the one I need. It's still not working though. Maybe I shouldn't be using php5.ini Maybe I should try to install PEAR in the same directory as my contact page.
Kris
The error I'm getting is include_path = .:/usr/local/php5/lib/php:/home/content/95/5788391/html/mywebsite/pear_admin/PEAR/Mail/Warning: include(Mail.php) [function.include]: failed to open stream: No such file or directory in /home/content/95/5788391/html/mywebsite/form.php on line 64
Kris
Does `/home/content/95/5788391/html/mywebsite/pear_admin/PEAR/Mail/Mail.php` actually exist? I'm thinking it'd actually be `/home/content/95/5788391/html/mywebsite/pear_admin/PEAR/Mail.php` with its own includes in a .../Mail subdir
Marc B
Sorry for the confusion. That was just me trying all options.
Kris
The path I need to use in my php5.ini is ending with /pear_admin/PEAR and that should do it but it gives me the following error include_path = .:/usr/local/php5/lib/php:/home/content/95/5788391/html/mywebsite/pear_admin/PEAR Warning: include(Mail.php) [function.include]: failed to open stream: No such file or directory in /home/content/95/5788391/html/mywebsite/form.php on line 64
Kris
I did a few tests and when I used require_once (“Mail.php”); it removed the . in my error message. That's the . between Mail.php .I don't think it matters all that much right now because from now on I'm only using include 'Mail.php';
Kris
I also created a new php5.ini , I even gave it a different name php.ini .That didn't help of course. That was just me starting to doubt everything. One last thing I should mention is that I'm using GoDaddy. I don't think that matters a lot but just to make sure...
Kris
PHP won't load just any .ini file you plunk down unless it's in a specific spot (or specified via httpd.conf/command line arg). If you do `phpinfo()` online, or `php -i` from the command line, it'll show you which ones it's actually loading, and where they are.
Marc B