php-general Digest 27 Jun 2009 06:16:35 -0000 Issue 6197

Topics (messages 294639 through 294666):

Re: This Friday's OT Thread
        294639 by: Robert Cummings
        294640 by: Bastien Koert
        294641 by: Michelle Konzack
        294642 by: Tom Worster
        294643 by: Daniel Brown
        294645 by: Arno Kuhl
        294664 by: Paul M Foster

Re: Regarding Accesing mp3 with php
        294644 by: Daniel Brown
        294646 by: tedd
        294647 by: Daniel Brown
        294648 by: Robert Cummings
        294649 by: Tom Chubb
        294652 by: tedd
        294653 by: Daniel Brown
        294654 by: tedd
        294655 by: Daniel Brown
        294657 by: tedd

Re: OT mysql pivot table problem
        294650 by: Matt Giddings
        294651 by: Shawn McKenzie

Re: XSS Preventing.
        294656 by: Chris Shiflett
        294663 by: Bastien Koert

Image Type BMP @ "Save Image As" Dialog on IE
        294658 by: Nitsan Bin-Nun

fixing new lines from <textarea> in an email?
        294659 by: Adam Williams
        294660 by: Daniel Brown
        294661 by: Adam Williams
        294666 by: WenDong Zhang

PHP 5.2.9 Apache 2.2.11 outputs php code on Vista
        294662 by: ioannes.btinternet.com
        294665 by: ioannes.btinternet.com

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
:(



Tom Worster wrote:
and Kaleem Omar.

and 15 people in Baghdad when motorcycle loaded with nails and ball-bearings
exploded in a crowded bazaar.



On 6/26/09 4:27 AM, "Robert Cummings" <rob...@interjinn.com> wrote:

Farah Fawcett has also died. I guess you gotta go sometime :|

Björn Bartels wrote:
Hello fellow coders...

THE 'KING OF POP' IS DEAD !

Tonight (here in Germany), Mr. Michael Joseph Jackson, also known as
'the king of pop',
died on heart failure in the age of 50.

I just want to express my condolences to his family and friends and
all the people
who loved him and his music.
This incomparable legendary musician has made such a big impact on
music and musicians
than any other artist in history.

Rest in peace, Mr. Jackson! And may you and your music never be
forgotten...




--
http://www.interjinn.com
Application and Templating Framework for PHP

--- End Message ---
--- Begin Message ---
2009/6/26 Robert Cummings <rob...@interjinn.com>:
> :(
>
>
>
> Tom Worster wrote:
>>
>> and Kaleem Omar.
>>
>> and 15 people in Baghdad when motorcycle loaded with nails and
>> ball-bearings
>> exploded in a crowded bazaar.
>>
>>
>>
>> On 6/26/09 4:27 AM, "Robert Cummings" <rob...@interjinn.com> wrote:
>>
>>> Farah Fawcett has also died. I guess you gotta go sometime :|
>>>
>>> Björn Bartels wrote:
>>>>
>>>> Hello fellow coders...
>>>>
>>>> THE 'KING OF POP' IS DEAD !
>>>>
>>>> Tonight (here in Germany), Mr. Michael Joseph Jackson, also known as
>>>> 'the king of pop',
>>>> died on heart failure in the age of 50.
>>>>
>>>> I just want to express my condolences to his family and friends and
>>>> all the people
>>>> who loved him and his music.
>>>> This incomparable legendary musician has made such a big impact on
>>>> music and musicians
>>>> than any other artist in history.
>>>>
>>>> Rest in peace, Mr. Jackson! And may you and your music never be
>>>> forgotten...
>>
>>
>>
>
> --
> http://www.interjinn.com
> Application and Templating Framework for PHP
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

According to twitter Jeff Goldblum also snuffed it, but that was a joke

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
...and no one care about the foreign (european) sniper WHO  killed  Neda
in Iran.

Note:   I can not reach my Company Website in Tehran nor can I reach  my
        Office over fixed telephone lines. I can not even contact one of
        my 57 employees  privately.  No  one  has  tried  to  access  my
        courier-imap or my webmail server in Germany...

F..king world...  and now Jackson?  WHO IS HE?



Am 2009-06-26 08:41:21, schrieb Tom Worster:
> and Kaleem Omar.
> 
> and 15 people in Baghdad when motorcycle loaded with nails and ball-bearings
> exploded in a crowded bazaar.
> 
> 
> 
> On 6/26/09 4:27 AM, "Robert Cummings" <rob...@interjinn.com> wrote:
> 
> > Farah Fawcett has also died. I guess you gotta go sometime :|
> > 
> > Björn Bartels wrote:
> >> Hello fellow coders...
> >> 
> >> THE 'KING OF POP' IS DEAD !
> >> 
> >> Tonight (here in Germany), Mr. Michael Joseph Jackson, also known as
> >> 'the king of pop',
> >> died on heart failure in the age of 50.
> >> 
> >> I just want to express my condolences to his family and friends and
> >> all the people
> >> who loved him and his music.
> >> This incomparable legendary musician has made such a big impact on
> >> music and musicians
> >> than any other artist in history.
> >> 
> >> Rest in peace, Mr. Jackson! And may you and your music never be
> >> forgotten...
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
------------------------ END OF REPLIED MESSAGE ------------------------
************************************************************************
*       Do not Cc: me, because I READ THIS LIST, if I write here       *
*    Keine Cc: am mich, ich LESE DIESE LISTE wenn ich hier schreibe    *
************************************************************************

Hello,


Thanks, Greetings and nice Day/Evening
    Michelle Konzack
    Systemadministrator
    24V Electronic Engineer
    Tamay Dogan Network
    Debian GNU/Linux Consultant


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack   Apt. 917                  ICQ #328449886
+49/177/9351947    50, rue de Soultz         MSN LinuxMichi
+33/6/61925193     67100 Strasbourg/France   IRC #Debian (irc.icq.com)

Attachment: signature.pgp
Description: Digital signature


--- End Message ---
--- Begin Message ---
On 6/26/09 9:20 AM, "Michelle Konzack" <linux4miche...@tamay-dogan.net>
wrote:

> ...and no one care about the foreign (european) sniper WHO  killed  Neda
> in Iran.

i don't know why you'd think that. the story is all over the news. american
pols have been exploiting it. cnn reports cia hay have been behind the
shooting.



--- End Message ---
--- Begin Message ---
On Fri, Jun 26, 2009 at 09:43, Tom Worster<f...@thefsb.org> wrote:
> On 6/26/09 9:20 AM, "Michelle Konzack" <linux4miche...@tamay-dogan.net>
> wrote:
>
>> ...and no one care about the foreign (european) sniper WHO  killed  Neda
>> in Iran.
>
> i don't know why you'd think that. the story is all over the news. american
> pols have been exploiting it. cnn reports cia hay have been behind the
> shooting.

    OT is one thing, fellas, but politics is another.  Please keep
that stuff to private emails or a more appropriate forum.

-- 
</Daniel P. Brown>
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Ask me about our fully-managed servers and proactive management
clusters starting at just $200/mo.!

--- End Message ---
--- Begin Message ---
-----Original Message-----
From: Michelle Konzack [mailto:linux4miche...@tamay-dogan.net] 
Sent: 26 June 2009 03:20 PM
To: php-gene...@lists.php.net
Subject: Re: [PHP] This Friday's OT Thread

...and no one care about the foreign (european) sniper WHO  killed  Neda in
Iran.

Note:   I can not reach my Company Website in Tehran nor can I reach  my
        Office over fixed telephone lines. I can not even contact one of
        my 57 employees  privately.  No  one  has  tried  to  access  my
        courier-imap or my webmail server in Germany...

F..king world...  and now Jackson?  WHO IS HE?
--

You've been living in a missile launcher for too long



--- End Message ---
--- Begin Message ---
On Fri, Jun 26, 2009 at 09:48:06AM -0400, Daniel Brown wrote:

> On Fri, Jun 26, 2009 at 09:43, Tom Worster<f...@thefsb.org> wrote:
> > On 6/26/09 9:20 AM, "Michelle Konzack" <linux4miche...@tamay-dogan.net>
> > wrote:
> >
> >> ...and no one care about the foreign (european) sniper WHO  killed  Neda
> >> in Iran.
> >
> > i don't know why you'd think that. the story is all over the news. american
> > pols have been exploiting it. cnn reports cia hay have been behind the
> > shooting.
> 
>     OT is one thing, fellas, but politics is another.  Please keep
> that stuff to private emails or a more appropriate forum.
> 

+1

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
On Fri, Jun 26, 2009 at 00:32, Gautam Bhatia<mail2gautambha...@gmail.com> wrote:
> hello all,
>             Is there anyway in php by which i can get the total play
> time of a mp3 , I found some information while doing the google thing
> using some 3rd party plug ins like getID3 but without any luck, Any help
> in this case would be helpful. Thank you.
> Regards,

    What issue were you facing when trying to use the (third-party)
getID3() function?

    Also, if you haven't already, check out ffmpeg-php
(http://ffmpeg-php.sourceforge.net/).

-- 
</Daniel P. Brown>
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Ask me about our fully-managed servers and proactive management
clusters starting at just $200/mo.!

--- End Message ---
--- Begin Message ---
At 10:02 AM +0530 6/26/09, Gautam Bhatia wrote:
hello all,
             Is there anyway in php by which i can get the total play
time of a mp3 , I found some information while doing the google thing
using some 3rd party plug ins like getID3 but without any luck, Any help
in this case would be helpful. Thank you.
Regards,

Gautam Bhatia .

Gautam:

I think that play time would be proportional to file size, right?

If so, then take two files and play them. Note the play times and file sizes of both and work out a algorithm. That would be the way I would try to solve it.

Cheers,

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On Fri, Jun 26, 2009 at 10:43, tedd<tedd.sperl...@gmail.com> wrote:
>
> I think that play time would be proportional to file size, right?
>
> If so, then take two files and play them. Note the play times and file sizes
> of both and work out a algorithm. That would be the way I would try to solve
> it.

    The compression algorithm used for encoding, frequency and quality
of the file, and actual noise signature itself would throw this off.
For example, a file with seven notes played in a period of 8 seconds
will be larger than a file with one note played at the same volume for
the same duration.  Then take into account the bitrate, if there are
ID3 tags or not, if there are compression comments embedded by the
encoding software....

-- 
</Daniel P. Brown>
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Ask me about our fully-managed servers and proactive management
clusters starting at just $200/mo.!

--- End Message ---
--- Begin Message ---
tedd wrote:
At 10:02 AM +0530 6/26/09, Gautam Bhatia wrote:
hello all,
             Is there anyway in php by which i can get the total play
time of a mp3 , I found some information while doing the google thing
using some 3rd party plug ins like getID3 but without any luck, Any help
in this case would be helpful. Thank you.
Regards,

Gautam Bhatia .

Gautam:

I think that play time would be proportional to file size, right?

If so, then take two files and play them. Note the play times and file sizes of both and work out a algorithm. That would be the way I would try to solve it.

Dear $_DEITY no. Filesize is barely related to play time. He's going aboutit the correct way, using existing libraries that know how retrieve the information. I would probably try ffplay (part of ffmpeg package):

    ffplay -an -stats THE_FILE.mp3

You'll see a line with the duration:

Input #0, mp3, from 'THE_FILE.mp3':
  Duration: 00:03:35.10, start: 0.000000, bitrate: 127 kb/s
    Stream #0.0: Audio: mp3, 44100 Hz, stereo, s16, 128 kb/s

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--- End Message ---
--- Begin Message ---
2009/6/26 Gautam Bhatia <mail2gautambha...@gmail.com>:
> hello all,
>             Is there anyway in php by which i can get the total play
> time of a mp3 , I found some information while doing the google thing
> using some 3rd party plug ins like getID3 but without any luck, Any help
> in this case would be helpful. Thank you.
> Regards,
>
> Gautam Bhatia .
>
>
>
>
I use this and find it very good: http://getid3.sourceforge.net/

Here is some code I'm using on one of my sites.
Bit messy - but it works for me :)

require_once('../public_html/audio/getid3/getid3.php');

function show_audio($type) {
        //Set path to audio files
        if ($type == "rmx") {
                $path = '/audio/productions/remixes/';
                $DirectoryToScan = '../public_html/audio/productions/remixes/';
                }
        elseif ($type == "pro") {
                $path = '/audio/productions/original/';
                $DirectoryToScan = '../public_html/audio/productions/original/';
                }

        $getID3 = new getID3;
        $dir = opendir($DirectoryToScan);
        while (($file = readdir($dir)) !== false) {
                $FullFileName = realpath($DirectoryToScan.'/'.$file);
                if (is_file($FullFileName)) {
                        set_time_limit(30);
                        $ThisFileInfo = $getID3->analyze($FullFileName);
                        getid3_lib::CopyTagsToComments($ThisFileInfo);
        
                        echo (!empty($ThisFileInfo['comments_html']['artist']) ?
implode('<BR>', $ThisFileInfo['comments_html']['artist']) : '&nbsp;')
. " - ";
                        echo (!empty($ThisFileInfo['comments_html']['title'])  ?
implode('<BR>', $ThisFileInfo['comments_html']['title'])  : '&nbsp;');
                        echo " (" . (!empty($ThisFileInfo['audio']['bitrate']) ?
round($ThisFileInfo['audio']['bitrate'] / 1000).' kbps'   : '&nbsp;')
. ") - ";
                        echo (!empty($ThisFileInfo['playtime_string'])         ?
$ThisFileInfo['playtime_string']                          : '&nbsp;')
. " - ";
                        echo '<a href = "' . $path . $file . 
'">Download</a><br>';
                }
        }
}


Then I simply upload audio files to the right directory and I don't
have to update the page that lists them.

--- End Message ---
--- Begin Message ---
At 10:49 AM -0400 6/26/09, Daniel Brown wrote:
    The compression algorithm used for encoding, frequency and quality
of the file, and actual noise signature itself would throw this off.
For example, a file with seven notes played in a period of 8 seconds
will be larger than a file with one note played at the same volume for
the same duration.  Then take into account the bitrate, if there are
ID3 tags or not, if there are compression comments embedded by the
encoding software....

AND

At 10:53 AM -0400 6/26/09, Robert Cummings wrote:
Dear $_DEITY no. Filesize is barely related to play time. He's going aboutit the correct way, using existing libraries that know how retrieve the information. I would probably try ffplay (part of ffmpeg package):

I stand corrected. Actually, I stand leaning a little to the right.

Cheers,

tedd


--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On Fri, Jun 26, 2009 at 11:17, tedd<tedd.sperl...@gmail.com> wrote:
>
> I stand corrected. Actually, I stand leaning a little to the right.

    And your mother dresses you funny.  ;-P

-- 
</Daniel P. Brown>
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Ask me about our fully-managed servers and proactive management
clusters starting at just $200/mo.!

--- End Message ---
--- Begin Message ---
At 11:22 AM -0400 6/26/09, Daniel Brown wrote:
On Fri, Jun 26, 2009 at 11:17, tedd<tedd.sperl...@gmail.com> wrote:

 I stand corrected. Actually, I stand leaning a little to the right.

    And your mother dresses you funny.  ;-P

Well, at least I had a mother.  :-)

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On Fri, Jun 26, 2009 at 11:42, tedd<tedd.sperl...@gmail.com> wrote:
>
> Well, at least I had a mother.  :-)

    Mrs. Sperling, Tedd's hurting my feelings!!!!

-- 
</Daniel P. Brown>
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Ask me about our fully-managed servers and proactive management
clusters starting at just $200/mo.!

--- End Message ---
--- Begin Message ---
At 11:46 AM -0400 6/26/09, Daniel Brown wrote:
On Fri, Jun 26, 2009 at 11:42, tedd<tedd.sperl...@gmail.com> wrote:

 Well, at least I had a mother.  :-)

    Mrs. Sperling, Tedd's hurting my feelings!!!!

Mom... he hurt my feeling first!

And his mother doesn't dress him as well as you do me.

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
Ummm yeah, its going to take me a while to wrap my head around that one.
 thanks though!
Matt

On Thu, Jun 25, 2009 at 5:07 PM, Andrew Ballard <aball...@gmail.com> wrote:

> On Thu, Jun 25, 2009 at 4:21 PM, Andrew Ballard<aball...@gmail.com> wrote:
> > On Thu, Jun 25, 2009 at 3:20 PM, Matt Giddings<mcgid...@svsu.edu> wrote:
> >> I know this is the off topic (sorry), but it is a php project that I'm
> >> working on!  I need some pointers on how to pivot a mysql column
> (containing
> >> comma delimited data) into an equal number of rows (see example).  Any
> >> direction (pointers to links, etc. would be appreciated).
> >>
> >> From this:
> >>
> >> user.table
> >> uid|name|groups
> >> 1|mcgiddin|1,4,7,10,12
> >>
> >>
> >> To this:
> >>
> >> pivot.table
> >> uid|group
> >> 1|1
> >> 1|4
> >> 1|7
> >> 1|10
> >> 1|12
> >>
> >
> > The best performance I've seen for a SQL solution uses a tally table.
> >
> > CREATE TABLE Tally (
> >    N int not null,
> >    PRIMARY KEY (N)
> > )
> >
> > The table holds a sequence of numbers from 1 to some large number.
> >
> > Then you can write a query something like this:
> >
> >  SELECT uid,
> SUBSTRING(user.table.groups,N+1,LOCATE(',',user.table.groups,N+1)-N-1)
> >   FROM Tally, user.table
> >  WHERE N < LENGTH(user.table.groups)
> >    AND SUBSTRING(user.table.groups,N,1) = ','
> >
> >
> >
> >
> > Andrew
> >
>
> OK, I actually tested this and it appears I missed something. For this
> query to work, the string has to begin and end with the delimiter. So
> I just replaced user.table.groups with CONCAT(',', user.table.groups,
> ',').
>
>  SELECT uid, SUBSTRING(CONCAT(',', user.table.groups,
> ','),N+1,LOCATE(',',CONCAT(',', user.table.groups, ','),N+1)-N-1)
>  FROM Tally, sample
>  WHERE N < LENGTH(CONCAT(',', user.table.groups, ','))
>   AND SUBSTRING(CONCAT(',', user.table.groups, ','),N,1) = ','
>
>
> For more in-depth information, check out some of the links in this search:
> http://www.google.com/search?q=sql+split+tally+table
>
>
> Andrew
>



-- 
Matt Giddings
Web Programmer
Information Technology Services
Saginaw Valley State University
Phone: 989.964.7247

http://www.svsu.edu

--- End Message ---
--- Begin Message ---
Matt Giddings wrote:
> Ummm yeah, its going to take me a while to wrap my head around that one.
>  thanks though!
> Matt

-- 
Matt Giddings
Web Programmer
Information Technology Services
Saginaw Valley State University
Phone: 989.964.7247

http://www.svsu.edu

I was born in Saginaw, Michigan.
I grew up in a house on Saginaw Bay.
My dad was a poor hard working Saginaw fisherman:
Too many times he came home with too little pay.

I loved a girl in Saginaw, Michigan.
The daughter of a wealthy, wealthy man.
But he called me: "That son of a Saginaw fisherman."
And not good enough to claim his daughter's hand.

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
On Jun 23, 2009, at 10:29, Martin Zvarík wrote:

Don't htmlentiies() before DB save.  In general:
- mysql_real_escape_string() before DB insertion
- htmlentities() before dispaly

I, on the other hand, would do htmlentities() BEFORE insertion.

Pros:
---
The text is processed once and doesn't have to be htmlentitied() everytime you read the database - what a stupid waste of performance anyway.

Isn't reading from the database every time a much bigger waste? Sounds like you might benefit from reading about Amdahl's law:

http://en.wikipedia.org/wiki/Amdahl%27s_law

Additionally, these slides from a talk by George Schlossnagle are good:

http://schlossnagle.org/~george/talks/ZendPerf.pdf

Amdahl's law aside, it does make sense in some cases (profiles for social apps, for example) to cache this information in a ready-to-be- displayed format, but no one should be talking about "performance" and "reading from the database every time" in the same sentence.

Chris

--
Chris Shiflett
http://shiflett.org/


--- End Message ---
--- Begin Message ---
On Fri, Jun 26, 2009 at 12:07 PM, Chris Shiflett<shifl...@php.net> wrote:
> On Jun 23, 2009, at 10:29, Martin Zvarík wrote:
>
>>> Don't htmlentiies() before DB save.  In general:
>>> - mysql_real_escape_string() before DB insertion
>>> - htmlentities() before dispaly
>>
>> I, on the other hand, would do htmlentities() BEFORE insertion.
>>
>> Pros:
>> ---
>> The text is processed once and doesn't have to be htmlentitied() everytime
>> you read the database - what a stupid waste of performance anyway.
>
> Isn't reading from the database every time a much bigger waste? Sounds like
> you might benefit from reading about Amdahl's law:
>
> http://en.wikipedia.org/wiki/Amdahl%27s_law
>
> Additionally, these slides from a talk by George Schlossnagle are good:
>
> http://schlossnagle.org/~george/talks/ZendPerf.pdf
>
> Amdahl's law aside, it does make sense in some cases (profiles for social
> apps, for example) to cache this information in a ready-to-be-displayed
> format, but no one should be talking about "performance" and "reading from
> the database every time" in the same sentence.
>
> Chris
>
> --
> Chris Shiflett
> http://shiflett.org/
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Fantastic PDF from the George Schlossnagle

http://schlossnagle.org/~george/talks/ZendPerf.pdf


Thanks

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
I have wrote a PHP script that serves JPEG images in smaller size, the
resize is done using GD on-the-fly.
I have noticed an interesting issue during the "save image as..." dialog on
serveral internet explorer browsers, somehow, for some strange reason, the
JPEG file is shown as BMP file.

I don't know why this is happening, but I'm trying to make it save it as JPG
file.
In firefox or any other browser everything works like a charm.

I have to mention that the JPG file is located in the HTML in the following
format:
<img src='xxx.jpg' alt='aaa' style='border:0;' />

I have also used mod_rewrite to serve the file with .jpg extension (I
thought that the strange IE may not know how to recognize it..), the PHP
file is sending the correct headers, I'm attaching an example for HTTP
request & response for this resized image:

GET /gallery-image-dolphinim-12450163853. HTTP/1.1
Host: www.dolphinim.net
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10)
Gecko/2009042316 Firefox/3.0.10 FirePHP/0.3
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: PHPSESSID=e4542edfa5bcb7904e351d39c341fffa

HTTP/1.x 200 OK
Date: Fri, 26 Jun 2009 16:18:52 GMT
Server: Apache/1.3.41 (Unix) PHP/5.2.6 mod_log_bytes/1.2 mod_bwlimited/1.4
mod_auth_passthrough/1.8 FrontPage/5.0.2.2635 DAV/1.0.3 mod_ssl/2.8.31
OpenSSL/0.9.8e-fips-rhel5
X-Powered-By: PHP/5.2.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
Pragma: no-cache
Keep-Alive: timeout=15, max=98
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: image/jpeg


Any directions will be highly appreciated!

Thanks!

--- End Message ---
--- Begin Message --- I have staff fill out a form that contains a <textarea> with their problem description and emailed to me when they click submit. Staff will press enter in the text area, but I'm having problems converting the \r\n into a new line in the email that is sent to me, here is the code:

$subject = "new support request #".mysqli_insert_id($mysqli);
$message = "Hello, ".$_SESSION["full_name"]." has created a new support request. Please log in at <a href=\"http://intra/helpdesk\";>MDAH Helpdesk</a>. The problem request is \"".htmlspecialchars(nl2br(str_replace('\r','',$_POST["problem"])))."\". and the best time to contact is \"".htmlspecialchars($_POST["contact_time"])."\".";
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: ".$_SESSION["full_name"]."<".$_SESSION["username"]."@mdah.state.ms.us>" ."\r\n" ."X-Mailer: PHP/" . phpversion();
mail('awill...@mdah.state.ms.us', $subject, $message, $headers);

and here is an example email, notice the \n is still in the body of the email, and it needs to be converted to a new line in the email:

Hello, Gwendolyn Jones has created a new support request. Please log in at MDAH Helpdesk <http://intra/helpdesk>. The problem request is "1 of 2 questions: I'm having trouble opening files from Jennifer, Susie, and Bill because they are working with a higher version of microsoft office. My version is 2003. Is there any way I could get an update on this?\n2 of 2 questions: I need permission to download a plug-in for the NPS site where I research NR properties.\nNeither of these questions/issues are urgent. Thanks. -Gwen". and the best time to contact is "Any time, phone # is cell".

why isn't nl2br converting the \n to <br> in the email?


--- End Message ---
--- Begin Message ---
On Fri, Jun 26, 2009 at 12:27, Adam Williams<awill...@mdah.state.ms.us> wrote:
> I have staff fill out a form that contains a <textarea> with their problem
> description and emailed to me when they click submit.  Staff will press
> enter in the text area, but I'm having problems converting the \r\n into a
> new line in the email that is sent to me, here is the code:
[snip!]


    In a cursory glance, I've noticed the following code:

htmlspecialchars(nl2br(str_replace('\r','',$_POST["problem"])))

    You are using a literal '\r' in your str_replace() function.  This
should instead be replaced with double quotes to translate the \r to
its appropriate EOL character:

htmlspecialchars(nl2br(str_replace("\r",'',$_POST["problem"])))

-- 
</Daniel P. Brown>
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Ask me about our fully-managed servers and proactive management
clusters starting at just $200/mo.!

--- End Message ---
--- Begin Message ---


Daniel Brown wrote:
    In a cursory glance, I've noticed the following code:

htmlspecialchars(nl2br(str_replace('\r','',$_POST["problem"])))

    You are using a literal '\r' in your str_replace() function.  This
should instead be replaced with double quotes to translate the \r to
its appropriate EOL character:

htmlspecialchars(nl2br(str_replace("\r",'',$_POST["problem"])))


Thanks, I didn't know that single vs double quotes in that instance made a difference. I've made the change to my code.


--- End Message ---
--- Begin Message ---
how about preg_replace('/(\\n}\\r\\n)/', '<br />', $_POST["problem"]);

On Sat, Jun 27, 2009 at 12:50 AM, Adam Williams
<awill...@mdah.state.ms.us>wrote:

>
>
> Daniel Brown wrote:
>
>>    In a cursory glance, I've noticed the following code:
>>
>> htmlspecialchars(nl2br(str_replace('\r','',$_POST["problem"])))
>>
>>    You are using a literal '\r' in your str_replace() function.  This
>> should instead be replaced with double quotes to translate the \r to
>> its appropriate EOL character:
>>
>> htmlspecialchars(nl2br(str_replace("\r",'',$_POST["problem"])))
>>
>>
>>
>
> Thanks, I didn't know that single vs double quotes in that instance made a
> difference.  I've made the change to my code.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Best Regards!
Wen Dong

--- End Message ---
--- Begin Message --- I have a working apache 2.2.11 server and php 5.2.9 installed.
APACHE CONFIGURATION
Files are in: C:/Program Files/Apache Software Foundation/Apache2.2/
Apache https.conf is amended to add at the end of the LoadModule lines (not between any tags):

   LoadModule php5_module "C:/PHP/php5apache2_2.dll"

   PHPIniDir "C:/PHP"

at the end of the file, though i cannot find any section called AddModule per the php installation notes ('Installing as an Apache module'):
   AddModule mod_php5.c
On clicking Start Apache http server, this gives "Invalid command 'AddModule' perhaps misspelled or defined by a module not included in server configuration." The PHP Installation guide says to add this at the end of the AddModule section. There is no AddModule in the default http.conf of Apache 2.2.11. So for now have commented it out.

and between <IfModule mime_module> and </IfModule>:

   AddType application/x-httpd-php .php

PHP CONFIGURATION
The php.ini file is in C:/PHP.
php.ini:
doc_root = "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs"

WINDOWS CONFIGURATION

I have added ;C:/PHP to the end of the string for Environment Variables.

I have re-booted and re-started.  I am testing this file:

C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test.php

which has
<?
print("test");
?>

and this outputs as code rather thna as 'test'.

When I start the Apache http server, I get:

httpd.exe: Could not reliably determine the server's fully qualified domain name
, using 10.0.0.4 for ServerName
(OS 10048)Only one usage of each socket address (protocol/network address/port)
is normally permitted.  : make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

My ISP has a dynamic IP address system, what do I use for ServerName? Do I need a static address or registered web site name to run on home computer?

Apache httpd.conf has:
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName
Any idea what might be wrong with the php code showing?

Thanks,

John




--- End Message ---
--- Begin Message ---
I meant httpd.conf.

And what is it about Vista that when in Notepad and you save a file, say test.php in directory htdocs, it shows test.php in the folder, but when you go to Windows Explorer there it is and it is gone? Nor does it load as http://localhost/test.php although http://localhost/ loads as the index.html file which is in the same folder?

Pathetic notes on installation of Apache.

J.

ioan...@btinternet.com wrote:
I have a working apache 2.2.11 server and php 5.2.9 installed.
APACHE CONFIGURATION
Files are in: C:/Program Files/Apache Software Foundation/Apache2.2/
Apache https.conf is amended to add at the end of the LoadModule lines (not between any tags):

   LoadModule php5_module "C:/PHP/php5apache2_2.dll"

   PHPIniDir "C:/PHP"

at the end of the file, though i cannot find any section called AddModule per the php installation notes ('Installing as an Apache module'):
   AddModule mod_php5.c
On clicking Start Apache http server, this gives "Invalid command 'AddModule' perhaps misspelled or defined by a module not included in server configuration." The PHP Installation guide says to add this at the end of the AddModule section. There is no AddModule in the default http.conf of Apache 2.2.11. So for now have commented it out.

and between <IfModule mime_module> and </IfModule>:

   AddType application/x-httpd-php .php

PHP CONFIGURATION
The php.ini file is in C:/PHP.
php.ini:
doc_root = "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs"

WINDOWS CONFIGURATION

I have added ;C:/PHP to the end of the string for Environment Variables.

I have re-booted and re-started.  I am testing this file:

C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test.php

which has
<?
print("test");
?>

and this outputs as code rather thna as 'test'.

When I start the Apache http server, I get:

httpd.exe: Could not reliably determine the server's fully qualified domain name
, using 10.0.0.4 for ServerName
(OS 10048)Only one usage of each socket address (protocol/network address/port)
is normally permitted.  : make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

My ISP has a dynamic IP address system, what do I use for ServerName? Do I need a static address or registered web site name to run on home computer?

Apache httpd.conf has:
# ServerName gives the name and port that the server uses to identify itself. # This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName
Any idea what might be wrong with the php code showing?

Thanks,

John





--- End Message ---

Reply via email to