php-general Digest 25 Oct 2006 07:45:12 -0000 Issue 4420
Topics (messages 243588 through 243601):
Problems with mail function
243588 by: Ricardo Ríos
243589 by: John Nichel
243592 by: Jochem Maas
243595 by: Chris
foreach on a 3d array
243590 by: Dotan Cohen
243591 by: Chris Boget
243593 by: Dotan Cohen
243594 by: M.Sokolewicz
243599 by: Ivo F.A.C. Fokkema
strtotime
243596 by: Ron Piggott (PHP)
243597 by: Chris
243598 by: Brad Chow
243600 by: Ivo F.A.C. Fokkema
[PEAR] QUICKFORM JSCALENDAR with "multiple dates feature"
243601 by: Marco Sottana
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Hi wizards, I 'm trying to use mail function in PHP, but this function don't
send the email , I have a server with postfix. Does somebody know how to
send an email with php and postfix. Thanks in advance.
--- End Message ---
--- Begin Message ---
Ricardo Ríos wrote:
Hi wizards, I 'm trying to use mail function in PHP, but this function
don't
send the email , I have a server with postfix. Does somebody know how to
send an email with php and postfix. Thanks in advance.
Does your install of postfix have a sendmail wrapper? Is it in the
normal sendmail location (/usr/bin/sendmail)? Is this on the same
machine as your php install? Does the user in which Apache is running
as have permission to invoke the sendmail wrapper?
--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
John Nichel wrote:
> Ricardo Ríos wrote:
>> Hi wizards, I 'm trying to use mail function in PHP, but this function
>> don't
>> send the email , I have a server with postfix. Does somebody know how to
>> send an email with php and postfix. Thanks in advance.
>>
>
> Does your install of postfix have a sendmail wrapper? Is it in the
> normal sendmail location (/usr/bin/sendmail)? Is this on the same
> machine as your php install? Does the user in which Apache is running
> as have permission to invoke the sendmail wrapper?
what does the error msg say? is display_errors on?
is error_reporting() set to E_ALL? ...
does he eat cheese? :-)
>
--- End Message ---
--- Begin Message ---
Ricardo Ríos wrote:
Hi wizards, I 'm trying to use mail function in PHP, but this function
don't
send the email , I have a server with postfix. Does somebody know how to
send an email with php and postfix. Thanks in advance.
Create a phpinfo page and make sure the 'sendmail_path' is set.
If that's set, you can just use php mail() as normal. The mail() command
doesn't care about what sort of MTA it uses, it just cares it knows
where it is and how to access it.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
I have an array that lloks like this:
$languages = array(
"af" => array("Afrikaans", "Afrikaans", "South Africa"),
"sq" => array("Albanian", "Shqipe", "Albania") );
Now, if the user's $_HTTP_ACCEPT_LANGUAGE contains, for example, "af",
I want to print the third value of the subarray for that value. This
code would not work, naturally, as I'm doing it wrong. I have been
unable to google a working example. Could someone please show me what
I'm doing wrong:
foreach ($languages as $language){
if ( strstr( $_HTTP_ACCEPT_LANGUAGE, $language) ) {
print"<center>You are from ".$language[2]."!</center>";
}
}
Thank in advance for any assistance.
Dotan Cohen
http://lyricslist.com/
http://what-is-what.com/
--- End Message ---
--- Begin Message ---
$languages = array(
"af" => array("Afrikaans", "Afrikaans", "South Africa"),
"sq" => array("Albanian", "Shqipe", "Albania") );
foreach ($languages as $language){
if ( strstr( $_HTTP_ACCEPT_LANGUAGE, $language) ) {
print"<center>You are from ".$language[2]."!</center>";
}
}
What you want is something like this:
foreach ($languages as $language => $valueArray ){
if ( strstr( $_HTTP_ACCEPT_LANGUAGE, $language) ) {
print"<center>You are from ".$valueArray[2]."!</center>";
}
}
Your example is setting the variable $language to the array for each
iteration.
So the first iteration,
$language is set to array("Afrikaans", "Afrikaans", "South Africa")
and the second iteration,
$language is set to array("Albanian", "Shqipe", "Albania")
thnx,
Chris
--- End Message ---
--- Begin Message ---
On 24/10/06, Chris Boget <[EMAIL PROTECTED]> wrote:
> $languages = array(
> "af" => array("Afrikaans", "Afrikaans", "South Africa"),
> "sq" => array("Albanian", "Shqipe", "Albania") );
>
> foreach ($languages as $language){
> if ( strstr( $_HTTP_ACCEPT_LANGUAGE, $language) ) {
> print"<center>You are from ".$language[2]."!</center>";
> }
> }
What you want is something like this:
foreach ($languages as $language => $valueArray ){
if ( strstr( $_HTTP_ACCEPT_LANGUAGE, $language) ) {
print"<center>You are from ".$valueArray[2]."!</center>";
}
}
Your example is setting the variable $language to the array for each
iteration.
Thanks, I see what I was missing.
So the first iteration,
$language is set to array("Afrikaans", "Afrikaans", "South Africa")
and the second iteration,
$language is set to array("Albanian", "Shqipe", "Albania")
That much I knew. Thanks, Chris.
Dotan Cohen
http://essentialinux.com/
http://technology-sleuth.com/
--- End Message ---
--- Begin Message ---
Dotan Cohen wrote:
On 24/10/06, Chris Boget <[EMAIL PROTECTED]> wrote:
> $languages = array(
> "af" => array("Afrikaans", "Afrikaans", "South Africa"),
> "sq" => array("Albanian", "Shqipe", "Albania") );
>
> foreach ($languages as $language){
> if ( strstr( $_HTTP_ACCEPT_LANGUAGE, $language) ) {
> print"<center>You are from ".$language[2]."!</center>";
> }
> }
What you want is something like this:
foreach ($languages as $language => $valueArray ){
if ( strstr( $_HTTP_ACCEPT_LANGUAGE, $language) ) {
print"<center>You are from ".$valueArray[2]."!</center>";
}
}
Your example is setting the variable $language to the array for each
iteration.
Thanks, I see what I was missing.
So the first iteration,
$language is set to array("Afrikaans", "Afrikaans", "South Africa")
and the second iteration,
$language is set to array("Albanian", "Shqipe", "Albania")
That much I knew. Thanks, Chris.
Dotan Cohen
http://essentialinux.com/
http://technology-sleuth.com/
Why not just do
if(isset($language[$_HTTP_ACCEPT_LANGUAGE])) {
print '<center>You are from
'.$language[$_HTTP_ACCEPT_LANGUAGE][3].'!</center>';
} else {
print '<center>where are you from?!</center>';
}
using strstr is pretty slow, and considering you made the indices
correspond to the actual value you're checking em for... this is a lot
faster ^^ (and cleaner IMO)
- tul
--- End Message ---
--- Begin Message ---
On Tue, 24 Oct 2006 23:55:49 +0200, M.Sokolewicz wrote:
> Dotan Cohen wrote:
>> On 24/10/06, Chris Boget <[EMAIL PROTECTED]> wrote:
>>> > $languages = array(
>>> > "af" => array("Afrikaans", "Afrikaans", "South Africa"),
>>> > "sq" => array("Albanian", "Shqipe", "Albania") );
>>> >
>>> > foreach ($languages as $language){
>>> > if ( strstr( $_HTTP_ACCEPT_LANGUAGE, $language) ) {
>>> > print"<center>You are from ".$language[2]."!</center>";
>>> > }
>>> > }
>>>
>>> What you want is something like this:
>>>
>>> foreach ($languages as $language => $valueArray ){
>>> if ( strstr( $_HTTP_ACCEPT_LANGUAGE, $language) ) {
>>> print"<center>You are from ".$valueArray[2]."!</center>";
>>> }
>>> }
>>>
>>> Your example is setting the variable $language to the array for each
>>> iteration.
>>
>> Thanks, I see what I was missing.
>>
>>> So the first iteration,
>>>
>>> $language is set to array("Afrikaans", "Afrikaans", "South Africa")
>>>
>>> and the second iteration,
>>>
>>> $language is set to array("Albanian", "Shqipe", "Albania")
>>
>> That much I knew. Thanks, Chris.
>>
>> Dotan Cohen
>>
>> http://essentialinux.com/
>> http://technology-sleuth.com/
>
> Why not just do
>
> if(isset($language[$_HTTP_ACCEPT_LANGUAGE])) {
> print '<center>You are from
> '.$language[$_HTTP_ACCEPT_LANGUAGE][3].'!</center>';
> } else {
> print '<center>where are you from?!</center>';
> }
Because that wouldn't work :)
This variable may contain stuff like "nl,en-us;q=0.7,en;q=0.3". You'll
need to do something with this variable first to use
array_key_exists (or as you do, isset). That said, I agree that
strstr() might not be the best solution.
An other note, Dotan: shouldn't $_HTTP_ACCEPT_LANGUAGE actually be
$_SERVER['HTTP_ACCEPT_LANGUAGE']?
Ivo
--- End Message ---
--- Begin Message ---
I have used the strtotime command to calculate a week ago (among other
things) with syntax like this:
$one_week_ago = strtotime("-7 days");
$one_week_ago = date('Y-m-d', $one_week_ago);
How would you use this command to figure out the last day of the month
in two months from now --- Today is October 24th 2006; the results I am
trying to generate are December 31st 2006. I want to keep the same
result until the end of October and then on November 1st and throughout
November the result to be January 31st 2007
Ron
--- End Message ---
--- Begin Message ---
Ron Piggott (PHP) wrote:
I have used the strtotime command to calculate a week ago (among other
things) with syntax like this:
$one_week_ago = strtotime("-7 days");
$one_week_ago = date('Y-m-d', $one_week_ago);
How would you use this command to figure out the last day of the month
in two months from now --- Today is October 24th 2006; the results I am
trying to generate are December 31st 2006. I want to keep the same
result until the end of October and then on November 1st and throughout
November the result to be January 31st 2007
Not great but you could do:
$two_months = strtotime("+2 months");
// get the bits you need for mktime
$num_of_days = date('t', $two_months);
$month = date('n', $two_months);
$year = date('Y', $two_months);
$last_day = mktime(0, 0, 1, $month, $num_of_days, $year);
echo 'date: ' . date('r', $last_day);
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
Dear Ron:
I have a solution as follows:
$date=("2006-10-26");
$date=strtotime($date);
$date=date('Y-m-1',$date);
$now=strtotime("+3 month", strtotime($date));
$lastday=strtotime("-1 day", $now);
echo date('Y-m-d',$lastday);
//2006-12-31
It's a very easy way to do you want.
I use strtotime to convert date to the first day of this month.
And, add 3 months to the day and subtract 1 day.
Then, you can get the day you want.
Regads,
----
Brad
On 10/25/06, Ron Piggott (PHP) <[EMAIL PROTECTED]> wrote:
I have used the strtotime command to calculate a week ago (among other
things) with syntax like this:
$one_week_ago = strtotime("-7 days");
$one_week_ago = date('Y-m-d', $one_week_ago);
How would you use this command to figure out the last day of the month
in two months from now --- Today is October 24th 2006; the results I am
trying to generate are December 31st 2006. I want to keep the same
result until the end of October and then on November 1st and throughout
November the result to be January 31st 2007
Ron
--- End Message ---
--- Begin Message ---
On Tue, 24 Oct 2006 20:36:08 -0400, Ron Piggott (PHP) wrote:
>
> I have used the strtotime command to calculate a week ago (among other
> things) with syntax like this:
>
> $one_week_ago = strtotime("-7 days");
> $one_week_ago = date('Y-m-d', $one_week_ago);
>
> How would you use this command to figure out the last day of the month
> in two months from now --- Today is October 24th 2006; the results I am
> trying to generate are December 31st 2006. I want to keep the same
> result until the end of October and then on November 1st and throughout
> November the result to be January 31st 2007
>
> Ron
My suggestion is:
$date = date('Y-m-t', strtotime('+2 months'));
$date = date('F jS Y', strtotime($date));
Only two lines of code, only four function calls. As you know, there are
many ways to do a thing.
Ivo
--- End Message ---
--- Begin Message ---
i find
jscalendar element for HTML_QuickForm
http://www.netsols.de/pear/jscalendar/
i need to use
multiple dates feature
http://www.dynarch.com/demos/jscalendar/multiple-dates.html
anyone can help me?
--- End Message ---