PDA

View Full Version : Questions about PHP include folder, PHP Scripts and Cron Jobs



emilybon
04-15-2012, 07:39 AM
Hi all,

I am trying to install PHPMailer and in the process learning a lot about using PHP scripts. I just have some questions that I have been looking for answers here in the forums but can't find the answers, or understand them, or there is so much variation in the answers I don't know which is right.

FYI, I am using two books to learn everything; PHP in Under 10 Minutes, and PHP and MySQL for Dummies. They are both helping me tremendously.

So, here I go:

1)

If using a PHP script and want it to be secure, the books suggest putting them in a folder hidden outside of the web root directory (outside the public_html folder) so that they can not be accessed by a browser (so that someone can't put the location in a browser address bar). To access this folder and run the scripts, the folder needs to be included (an include code linking to the folder) in the php.ini file. But the php.ini file already has a location that it links to as follows:


; UNIX: "/path1:/path2"
include_path = ".:/usr/lib64/php:/usr/lib/php"
;
; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"

Now I seem to have two options, 1) put my scripts in this location that should already exist, or 2) create a new folder and include link.

I would prefer to put my scripts into the already existing folder, but I can't find it.

QUESTION 1) Where can I find the already existing include folder that is linked to in the php.ini file?
QUESTION 1 part 2) If the folder doesn't exist, is it okay to create a new folder in the user root directory (home/username/new folder)?
QUESTION 1 part 3) If I create the new folder, what is the new code to include in the php.ini? (please write out the entire code to include because I am a dummie!)

QUESTION 2) After I set up this php include folder, will I be able to just place any future php script files into that folder and have it automatically connected/included to run without having to write anymore include codes anywhere?


2)

Most of what I am trying to do has databases involved. So, I have the code to connect to the database and then the php script.

QUESTION 1) What is the best practice to write the files? Should I put the database connect code in its own file and then include it in the php scripts that use use that database (this might be best if I am using many scripts to work with one database)? Or should I write the database connect code at the top of the same file as the php script?

QUESTION 2) Can I place two php scripts in the same file? I have two scripts that are the same except for one line change.

3)

Cron Jobs:

I found this https://my.bluehost.com/cgi/help/480 that says the cron job command should be this:

php -c /home/username/public_html/php.ini /home/username/public_html/myscript.php

and then I found this https://my.bluehost.com/cgi/help/168 that says the cron job command should be this:

/ramdisk/bin/php5 -c /home/USERNAME/PathTo/php.ini /home/USERNAME/public_html/PathToFile

QUESTION 3) Which command is correct?

Thank you for your help.