Zoran Lorkovic wrote:

$file = file_get_contents("text.inc"); $start = "[start]"; $end = "[/end]"; $pos_start = strpos ($file, $start); $pos_end = strpos ($file, $end); $data = substr ($file, $pos_start, $pos_end); mail ("[EMAIL PROTECTED]", "My Subject", $data);


This code works when I call it from browser, but when I call it from command line, $data is not put into mail (mail is send but it is empty, without any data in body).

File text.inc looks like this: [start]some_text_goes_here[/end] [other_start]other_text_goes_here[/other_end]

Regards.


that would depend from which place you run the script.
file_get_contents("text.inc") will be looked for in:
1. the current working directory
2. the included dirs

So, if you're running the script like:
[EMAIL PROTECTED] /]# cd /
[EMAIL PROTECTED] /]# php -q /var/www/html/scripts/mail.php
then you're actually working in /, so it's looking for "text.inc" in:
/text.inc and in all include-paths.

Now, usually you can fix such a thing by using:
chdir(dirname(__FILE__)); at the top of the script to force it to work in the directory the script itself is in.


However, when you call it from the browser, via the server, it will always run from the path the script is located in. (the extra chdir() won't cause any problems though)

Hope that helps,
- Tul

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to