php-general Digest 1 Feb 2006 06:38:39 -0000 Issue 3938

Topics (messages 229571 through 229604):

Re: strange behaviour with strtotime()
        229571 by: Ford, Mike

Re: html forms and php
        229572 by: Ford, Mike

Re: form variables issue
        229573 by: Weber Sites LTD
        229574 by: Richard Correia
        229599 by: Richard Lynch

Re: Problems with realpath()
        229575 by: Richard Correia

Re: image uploads
        229576 by: Weber Sites LTD
        229581 by: Richard Lynch
        229588 by: tedd
        229589 by: Weber Sites LTD
        229592 by: Richard Lynch

SQL in XML [was PHP and DBase...]
        229577 by: David BERCOT
        229578 by: Miles Thompson
        229579 by: David BERCOT
        229580 by: Daevid Vincent
        229595 by: Richard Lynch
        229596 by: Richard Lynch

Re: Question about C++ like macros on PHP
        229582 by: Richard Lynch
        229583 by: Richard Lynch

CR \ LFs being represented as ascii characters in output of mail()
        229584 by: Murray . PlanetThoughtful
        229585 by: James Benson
        229602 by: Chris Shiflett

Re: Embed XHTML code using PHP's XSLT processor
        229586 by: Björn Bartels

session loss
        229587 by: Dave Goodchild
        229590 by: Richard Correia
        229591 by: Ray Hauge

Re: Problems with GZIPped content in some cases?!?
        229593 by: Richard Lynch

Re: PHP and DBase...
        229594 by: Richard Lynch

Re: Clean data / text for XML
        229597 by: Richard Lynch

Re: Class constructor
        229598 by: Richard Lynch

Re: PHP session_id()
        229600 by: Richard Lynch

Re: PHP5 Build - test.php not working
        229601 by: Richard Lynch

Running snippets from within PHP
        229603 by: Eli

Re: HTML Question?
        229604 by: William Stokes

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:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On 31 January 2006 15:41, Barry wrote:

> Ford, Mike wrote:
> > Yes, but 1 apple is 1 apple is 1 apple.
> > 
> > 1 month can be 28 days, or 31 days, or anything in between.
> 2 months can be anything from 59 to 62 days.
> > 
> > A month is an imprecise measure, and adding them together
> will get you an even more imprecise result.
> > 
> > Deal with it -- that's just the way it is.
> > 
> > Cheers!
> 
> And now you tell me how the strtotime function tells what to use
> either 28 days or 31 days or 4 3/87 days.

It's very simple.  It uses the same day-of-the-month you start from: 1st gets 
you the 1st; 15th gets you the 15th; 31st gets you 31st or equivalent).  Put 
another way, "+1 month" adds as many days as there are days in the starting 
month; "+2 months" adds as many days as there are in the starting month and the 
one after (starting in Jan: 31+28 = 59 -- but starting in, say, Jul: 31+31 = 
62); and so on.

Most of the time this gives you exactly what you want -- it's only when you ask 
starting from the 29th, 30th or 31st of a month, and the destination month is 
shorter, that it causes any kind of problem.  Since this is a very small, 
well-defined range of dates, it's fairly simple to deal with it -- once you 
know you need to!!

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--- End Message ---
--- Begin Message ---
On 31 January 2006 16:08, Philippe Reynolds wrote:

> I added the square brakets to the name...now when I select
> all the options
> on the list I can read all values individually.
> 
> Here is problem...my javascripts have stopped working, I
> can't move options
> from one list to the next.  Here is the javascript I use
> currently...I would like help in modifing it so that it may work
> while using the 
> brakets on the
> name of the select:

Use the Javascript identity of x.y with x["y"], thusly:

>    <input type="button" name="SelectAll" value=">> All" style="width:
> 100px;" onClick="MoveAll(fleetForm.trucklist,
> fleetForm.reportinglist)"><br>

   onclick="MoveAll(fleetForm['trucklist[]'], fleetForm['reportinglist[]'])"

No need to mess about with the complications of DOM and getElementById -- it's 
much more backward compatible for older browsers, as well, since that identity 
has existed since day one of JavaScript.

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--- End Message ---
--- Begin Message ---
I'm not sure I understand the problem.
Can you send a link to the page and post some code?

Sincerely 
 
berber 
 
Visit the Weber Sites Today, 
To see where PHP might take you tomorrow. 
PHP code examples : http://www.weberdev.com 
Free Uptime Monitor : http://uptime.weberdev.com
PHP content for your site : http://content.weber-sites.com
 

-----Original Message-----
From: All U Want [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 31, 2006 1:04 PM
To: [php] PHP General List
Subject: [PHP] form variables issue

Hi folks,

I'm sure it is a very simple question for you but I'm getting almost crazy.

I've got a simple form with several form objects, one of them is a text
field. After submitting the form if one of the form objects hasn't been
modified I will show the same form but keeping the data previously
introduced. My problem is the text field, I can't show any special
characters again, even if there was any space only the first word is shown,
etc.

I've been playing with different function like urldecode, urlencode,
stripslashes, htmlspecialchars, etc. but couldn't show the same text.

Do  you know how I can fix this?


Thanks a lot,
David.

Note that magic_quotes_gpc is enabled.

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

--- End Message ---
--- Begin Message ---
Can you check the source code?

are there values in source, but it is not displayed on the browser?

<input type=text value=My Name is Richard name=first_name>

check this code snippet

<?php
echo get_magic_quotes_gpc();         // 1
echo $_POST['lastname'];             // O\'reilly
echo addslashes($_POST['lastname']); // O\\\'reilly

if (!get_magic_quotes_gpc()) {
   $lastname = addslashes($_POST['lastname']);
} else {
   $lastname = $_POST['lastname'];
}

echo $lastname; // O\'reilly
$sql = "INSERT INTO lastnames (lastname) VALUES ('$lastname')";
?>

Thanks
Richard

On 1/31/06, All U Want <[EMAIL PROTECTED]> wrote:
>
> Hi folks,
>
> I'm sure it is a very simple question for you but I'm getting almost
> crazy.
>
> I've got a simple form with several form objects, one of them is a
> text field. After submitting the form if one of the form objects
> hasn't been modified I will show the same form but keeping the data
> previously introduced. My problem is the text field, I can't show any
> special characters again, even if there was any space only the first
> word is shown, etc.
>
> I've been playing with different function like urldecode, urlencode,
> stripslashes, htmlspecialchars, etc. but couldn't show the same text.
>
> Do  you know how I can fix this?
>
>
> Thanks a lot,
> David.
>
> Note that magic_quotes_gpc is enabled.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On Tue, January 31, 2006 5:03 am, All U Want wrote:
> I'm sure it is a very simple question for you but I'm getting almost
> crazy.
>
> I've got a simple form with several form objects, one of them is a
> text field. After submitting the form if one of the form objects
> hasn't been modified I will show the same form but keeping the data
> previously introduced. My problem is the text field, I can't show any
> special characters again, even if there was any space only the first
> word is shown, etc.
>
> I've been playing with different function like urldecode, urlencode,
> stripslashes, htmlspecialchars, etc. but couldn't show the same text.
>
> Do  you know how I can fix this?

The first big problem is that you are outputting stuff like this:

<input name=foo value=this value has whitespace so is not a value />

instead of this:

<input name="foo" value="this value has whitespace but quotes matter" />

You should call http://php.net/htmlentities on the data right before
you print it into the HTML page.

<?php $value_html = htmlentities($value)?>
<input name="foo" value="<?php echo $value_html?>" />

> Note that magic_quotes_gpc is enabled.

In that case, you need to call http://php.net/stripslashes on the data
before you do anything with it, except to cram it into a database.

magic_quotes_gpc *ONLY* made sense in the context of the early days of
PHP when 99.9999999% of the data was just getting tossed into a MySQL
database and there were a lot less Bad Guys around -- when it was all
guestbooks and lovey-dovey surfers.

In today's world, Magic Quotes should probably just die...

It's a shame, in a way, in that Magic Quotes is a nice simple solution
to those simplistic applications that are just tossing data into a
database, and not doing much else.  But PHP has grown up a lot since
then, and the world is a different place.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
I think the DOCUMENT_ROOT is changed for new php implementation.

Thanks
Rich


On 1/31/06, Ron King <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> My hosting isp just upgraded from 4.3.1 to 4.4.1, and some of the
> tools I use (from InterAKT) no longer work.
>
> After doing quite a bit of research, I've seen a few bugs regarding
> realpath(), but none related to 4.4.1.
>
> When I try the following:
>
> <?php
>    echo phpversion() . "\n";
>    echo dirname(__FILE__) . "\n";
>    echo realpath(__FILE__);
> ?>
>
> With version 4.4.0, I get the following answer:
>
> 4.4.0
> /web
> /web/realpath.php
>
> But on version 4.4.1 I get a fatal error:
>
> 4.4.1
> /data/...      <-- different server, therefore different path, of course
> Fatal error: Call to undefined function: realpath() in /data/...).
>
> I'm too much of a newbie to know what to do on my own. Is this
> something my ISP has turned off?
>
> Thanks for any help,
>
> -- Ron
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Check this out : 

http://www.weberdev.com/get_example-3938.html
Image Upload And Resize Script

Sincerely 
 
berber 
 
Visit the Weber Sites Today, 
To see where PHP might take you tomorrow. 
PHP & MySQL Forums : http://www.weberforums.com
Learn PHP & MySQL Playing Trivia : http://www.webertrivia.com
 

-----Original Message-----
From: William Stokes [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 31, 2006 6:58 PM
To: php-general@lists.php.net
Subject: [PHP] image uploads

Hello,

Is there something special about php and images that nobody told me...

I'm writing a image gallery but I have  run to serious trouble with it. I
have one page with form in it. Form's action is $PHP_SELF. In the form there
is just one file field called "image".

I test if there's users image to handle with if (isset($img))

if there's one. I greate two new images using

imagecreatefromjpeg()
imagecreatetruecolor()
imagecopyresampled()

in two different functions. At the end of both functions there's
imagedestroy($img). After that the both image information is stored to DB
and, if succeful, at the end I do unset($img) to clear the old image
variable from memory. Both new images are created OK and DB update works OK.

But nothing else doesn't work. I don't know what I have to do to prevent the
image from realoading to server second time if user hits browser refresh
button. The same image is uploaded every time the user hits refresh. Another
thing is that Opera stopped co-operation with this page once and for all. It
just freezes after the page call's itself. IE and Firefox doesn't.

I Really need some help

Thanks
-Will





 

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

--- End Message ---
--- Begin Message ---
On Tue, January 31, 2006 10:58 am, William Stokes wrote:
> Is there something special about php and images that nobody told me...

No. :-)

> I'm writing a image gallery but I have  run to serious trouble with
> it. I
> have one page with form in it. Form's action is $PHP_SELF. In the form
> there
> is just one file field called "image".

Add the ENCTYPE="multipart/form-data" to the FORM tag, if you don't
have it.

> I test if there's users image to handle with
> if (isset($img))

You mean isset($image), right?...
The name above is "image"...

Post source code snippets.

> if there's one. I greate two new images using
>
> imagecreatefromjpeg()
> imagecreatetruecolor()
> imagecopyresampled()
>
> in two different functions. At the end of both functions there's
> imagedestroy($img). After that the both image information is stored to
> DB

Storing the image in the DB is probably not a Good Idea for a variety
of reasons.

There is a highly-optimized much more mature specialized database
specifically designed for large-file operations (LFO)...

It's called "the file system" :-)

> and, if succeful, at the end I do unset($img) to clear the old image
> variable from memory. Both new images are created OK and DB update
> works OK.

OK...

> But nothing else doesn't work.

You'd have to give us a lot more than "doesn't work"...

We've got nothing to work on here.

> I don't know what I have to do to
> prevent the
> image from realoading to server second time if user hits browser
> refresh
> button. The same image is uploaded every time the user hits refresh.

Well, yeah, if they upload the same image again, then you're going to
get it again.

If you don't want to allow that, then include a unique token
http://php.net/uniqid in the form you send them, and when they upload
the first image, mark that token as "used" and don't let them do it
again.

You could also do a binary-safe string comparison of the new image
with the images already in the database -- That would be slower, but
would dis-allow somebody from filling out the form again with a new
token and uploading the same image a second time.

> Another
> thing is that Opera stopped co-operation with this page once and for
> all. It
> just freezes after the page call's itself. IE and Firefox doesn't.

Opera freezing up is probably a separate problem entirely.  Ignore it
until you get the application working the way you want it to work.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
Richard said:

Storing the image in the DB is probably not a Good Idea for a variety
of reasons.

And they are?

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

--- End Message ---
--- Begin Message ---
The main reason I don't like storing the images in the DB is because
File system is much more fast then DB. FS and the web server know
How to cache images while using the DB makes you access the 
DB for each and every picture.

It's also harder to maintain cause you don't have a physical file you can 
Move from place to place or from dir to dir. Or just look at a bunch of
Random images like you would in a directory.

>From my point of view there has to be a very good reason to put images
Inside a DB instead of in the file system.

Sincerely 
 
berber 
 
Visit the Weber Sites Today, 
To see where PHP might take you tomorrow. 
Free Uptime Monitor : http://uptime.weberdev.com
PHP content for your site : http://content.weber-sites.com
 

-----Original Message-----
From: tedd [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 01, 2006 12:43 AM
To: php-general@lists.php.net
Subject: Re: [PHP] image uploads

Richard said:

>Storing the image in the DB is probably not a Good Idea for a variety 
>of reasons.

And they are?

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

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

--- End Message ---
--- Begin Message ---
On Tue, January 31, 2006 4:43 pm, tedd wrote:
>>Storing the image in the DB is probably not a Good Idea for a variety
>>of reasons.
>
> And they are?

... in the archives.

http://marc.theaimsgroup.com/?l=php-general

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
> > Hi,
> > 
> > I'd like to connect to DBase files (.dbf) in order to do SQL requests.
> > Do you know if it is possible ?
> > If yes, do you have an example ?
> > I'm working on Debian with PHP5.
> > 
> > Thank you very much.
> > 
> > David.
> Blind?
> 
> http://de.php.net/dbase

OK. I should have made such a search ;-)
So, it is possible... I'll try...

But, finally, I wonder if I shouldn't use XML files instead ?
Is it possible, directly, to make a SQL request on a XML file ?

In fact, I was looking for a file format which would be modifing on
Windows and on Linux. So, I thought about dbf. But now...

Thank you very much.

David.

--- End Message ---
--- Begin Message ---
At 03:08 PM 1/31/2006, David BERCOT wrote:

> > Hi,
> >
> > I'd like to connect to DBase files (.dbf) in order to do SQL requests.
> > Do you know if it is possible ?
> > If yes, do you have an example ?
> > I'm working on Debian with PHP5.
> >
> > Thank you very much.
> >
> > David.
> Blind?
>
> http://de.php.net/dbase

OK. I should have made such a search ;-)
So, it is possible... I'll try...

But, finally, I wonder if I shouldn't use XML files instead ?
Is it possible, directly, to make a SQL request on a XML file ?

In fact, I was looking for a file format which would be modifing on
Windows and on Linux. So, I thought about dbf. But now...

Thank you very much.

David.


David,

If I remember correctly, there are a lot of caveats surrounding .dbf files.
If it is data you have to manage, why not use MySQL / PostgresSQl / Firebird?

Cheers - Miles

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.1.375 / Virus Database: 267.14.25/246 - Release Date: 1/30/2006

--- End Message ---
--- Begin Message ---
> > > > Hi,
> > > >
> > > > I'd like to connect to DBase files (.dbf) in order to do SQL requests.
> > > > Do you know if it is possible ?
> > > > If yes, do you have an example ?
> > > > I'm working on Debian with PHP5.
> > > >
> > > > Thank you very much.
> > > >
> > > > David.
> > > Blind?
> > >
> > > http://de.php.net/dbase
> >
> >OK. I should have made such a search ;-)
> >So, it is possible... I'll try...
> >
> >But, finally, I wonder if I shouldn't use XML files instead ?
> >Is it possible, directly, to make a SQL request on a XML file ?
> >
> >In fact, I was looking for a file format which would be modifing on
> >Windows and on Linux. So, I thought about dbf. But now...
> >
> >Thank you very much.
> >
> >David.
> 
> 
> David,
> 
> If I remember correctly, there are a lot of caveats surrounding .dbf files.
> If it is data you have to manage, why not use MySQL / PostgresSQl / Firebird?

In fact, it is only for one table. And I'd like a simple thing. For my
data, I use Oracle !!!

David.

--- End Message ---
--- Begin Message ---
> But, finally, I wonder if I shouldn't use XML files instead ?
> Is it possible, directly, to make a SQL request on a XML file ?

How much data are you storing and how fast do you need it?

If you're doing heavy "database" type queries, then just use mySQL.

XML is kind of a PITA to use IMHO. You have to set up DOM Objects and all
this crap, then loop over nodes and use xpaths and watch out for #text
elements and it's just messy. I'm forced to use XML for part of a project @
work, and I'm always grateful when I can switch back to using a database and
SQL as God intended it to be. ;-p

However, if you're just storing some basic configs or preferences, then I
would suggest looking into a much simpler (and universal):

http://www.php.net/parse_ini_file

--- End Message ---
--- Begin Message ---
On Tue, January 31, 2006 1:08 pm, David BERCOT wrote:
>> > Hi,
>> >
>> > I'd like to connect to DBase files (.dbf) in order to do SQL
>> requests.
>> > Do you know if it is possible ?
>> > If yes, do you have an example ?
>> > I'm working on Debian with PHP5.
>> >
>> > Thank you very much.
>> >
>> > David.
>> Blind?
>>
>> http://de.php.net/dbase
>
> OK. I should have made such a search ;-)
> So, it is possible... I'll try...
>
> But, finally, I wonder if I shouldn't use XML files instead ?
> Is it possible, directly, to make a SQL request on a XML file ?
>
> In fact, I was looking for a file format which would be modifing on
> Windows and on Linux. So, I thought about dbf. But now...

MySQL and PostgreSQL both work on Windows (and Linux, duh).

If you're starting a NEW database project, DBase is the LAST thing I'd
choose, unless there's some over-riding concern you've not yet
mentioned.

Actually, DBase doesn't even seem to use SQL, so I suppose your
question could have been:  "Is there any way to tie standard SQL into
DBase, instead of using the normal PHP DBase extension?"...

I'm pretty sure both PostgreSQL and MySQL allow you to input/output
data as XML.

For sure, MySQL has a new Engine type where you can act upon a CSV
file using SQL which is the closest match to what you seem to be
aiming towards...

Though I still suspect your aim is bad, tell you the truth...

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Tue, January 31, 2006 1:49 pm, David BERCOT wrote:

After reading more and more of this thread, I think you should also
consider this option:

http://www.php.net/sqllite

It lets you use SQL, and it stores the data in a local file, and it's
quite lightweight/cheap/easy.

Personally, though, I'd just toss the table in Oracle and use the
tools you already have, rather than maintain yet another paradigm
within the application...

YMMV

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Tue, January 31, 2006 6:20 am, Andrei wrote:
>       For debugging purposes I want to send to a function the line and file
> where it is called. The problem is that I want these parameters to be
> added to function as default parameters (changing all function calls
> would not be an option for me)
>
> function my_func( $param, $line = __LINE__, $file = __FILE__ )
> {
>     ...
> }
>
> won't work as it always gets the file and line where function is
> defined.
>       Also I don't want to change all function calls to put __LINE__ and
> __FILE__ parameters.
> I looked into assert too, but I have to change again all function
> calls
> to be assert( "my_func(...)" ); which again will be a pain in the a...
> as this function is often called in every scripts...

http://php.net/set_error_handler

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Tue, January 31, 2006 6:40 am, Andrei wrote:
> Well I know, I wanted to know if any1 did find a workaround...

To be more clear, since obviously several other posters aren't aware
of it...

http://php.net/set_error_handler allows you to write a function to be
called when an error occurs and that function accepts optional
arguments of $file and $line which PHP will fill with the __FILE__ and
__LINE__ values of the offending code.

Which is precisely what you need.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
Hi All,

I'm having an odd problem with formatting of line feeds in an email my site automatically sends to me when someone comments on one of my blog entries.

For some reason "\r\n" characters are coming through exactly like that in the email, and yet the same value being stored in the backend MySQL database seems to represent the carriage-return \ line-feed characters as it should.

A typical example of the value when sent in the email would be:

Lol, hi Duncan.\r\n\r\nIt\'s possible that this post once had some comments. I 
lost most of PT at one point when my host had a harddrive crash, and salvaged a 
lot of entries from local copies on my computer, and notes I\'d scribbled in my 
journals and so on.\r\n\r\nStill, it\'s great to see you commenting on the post 
that made you a legend on PT!\r\n\r\nMuch warmth,\r\n\r\nMr Banderas

The odd thing is that the rest of the email is correctly interpreting line-feed characters, it's only the value entered on the comment form that represents CR \ LFs as normal characters.

I'm not sure if this is the culprit, but because my remote host for this site has magic_quotes_gpc on, and my local setup doesn't, I run the following function every time a page is requested where form processing is performed:

  function traverse ( &$arr )
  {
      if ( !is_array ( $arr ) )
          return;

      foreach ( $arr as $key => $val )
is_array ( $arr[$key] ) ? traverse ( $arr[$key] ) : ( $arr[$key] = stripslashes ( $arr[$key] ) );
  }

Can anyone give me any thoughts on how to represent these CR \ LF characters properly in the email?

Many thanks,

Murray

--
"Lost in thought" :-
http://www.planetthoughtful.org

---

"A blog devoted to urban legends,
superstitions, ghost stories, and
all things folkloric." :-

http://www.ulblog.org

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



Murray @ PlanetThoughtful wrote:
> Hi All,
> 
> I'm having an odd problem with formatting of line feeds in an email my
> site automatically sends to me when someone comments on one of my blog
> entries.
> 
> For some reason "\r\n" characters are coming through exactly like that
> in the email, and yet the same value being stored in the backend MySQL
> database seems to represent the carriage-return \ line-feed characters
> as it should.
> 
> A typical example of the value when sent in the email would be:
> 
> Lol, hi Duncan.\r\n\r\nIt\'s possible that this post once had some
> comments. I lost most of PT at one point when my host had a harddrive
> crash, and salvaged a lot of entries from local copies on my computer,
> and notes I\'d scribbled in my journals and so on.\r\n\r\nStill, it\'s
> great to see you commenting on the post that made you a legend on
> PT!\r\n\r\nMuch warmth,\r\n\r\nMr Banderas
> 
> The odd thing is that the rest of the email is correctly interpreting
> line-feed characters, it's only the value entered on the comment form
> that represents CR \ LFs as normal characters.
> 
> I'm not sure if this is the culprit, but because my remote host for this
> site has magic_quotes_gpc on, and my local setup doesn't, I run the
> following function every time a page is requested where form processing
> is performed:
> 
>   function traverse ( &$arr )
>   {
>       if ( !is_array ( $arr ) )
>           return;
> 
>       foreach ( $arr as $key => $val )
>           is_array ( $arr[$key] ) ? traverse ( $arr[$key] ) : (
> $arr[$key] = stripslashes ( $arr[$key] ) );
>   }
> 
> Can anyone give me any thoughts on how to represent these CR \ LF
> characters properly in the email?
> 
> Many thanks,
> 
> Murray
> 



you probably have it surrounded in single quotes, PHP only converts \n
or \r\n when its enclosed within double quotes


James



---------------------------------------------------------

Master CIW Designer          http://www.ciwcertified.com
Zend Certified Engineer      http://www.zend.com


http://www.jamesbenson.co.uk

---------------------------------------------------------

--- End Message ---
--- Begin Message ---
Murray @ PlanetThoughtful wrote:
For some reason "\r\n" characters are coming through exactly like
that in the email, and yet the same value being stored in the
backend MySQL database seems to represent the carriage-return \
line-feed characters as it should.

Sounds like you're using data that's been escaped with something like mysql_real_escape_string(). You want to do that when you're using it in a MySQL query, not when you use it in an email.

Hope that helps.

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

--- End Message ---
--- Begin Message ---
Moin, moin...

>Why doesn't 'xsl:element' indent the xml data according to the ident
>switch
>("yes"/"no") then? I expected that the complete resulting XHTML
>(generated
>by the XSLT processor) is either indented or it's completely not
>indented.
>Unfortunately this is not the case for the imported XHTML from the XML
>file.

I'm only 99% sure but I think in this line...

<xsl:apply-templates select="node()" > 

..."node()"  returns  "CDATA"  which drops
those unnessasary whitespaces and cr/lf's...

cheers,
bb

Björn Bartels
-Development/IT-Services-

----------------------------------------------
dbusiness.de gmbh
digital business & printing gmbh

Greifswalder Str. 152
D-10409 Berlin

Fon: [0.30] 4.21.19.95
Fax: [0.30] 4.21.19.74

www.dbusiness.de
[EMAIL PROTECTED]
ftp://dbusiness.dyndns.org

--- End Message ---
--- Begin Message ---
Hi all - does anyone know why, in certain cases, session variables are lost
from the $_SESSION superglobal array? I am writing a session-driven app and
for some reason the testing crew lose a certain variable while traversing
forms but I cannot replicate the situation myself. Any knowledge of this
will be appreciated!

--- End Message ---
--- Begin Message ---
Which php version and platform?

Thanks
Rich

On 2/1/06, Dave Goodchild <[EMAIL PROTECTED]> wrote:
>
> Hi all - does anyone know why, in certain cases, session variables are
> lost
> from the $_SESSION superglobal array? I am writing a session-driven app
> and
> for some reason the testing crew lose a certain variable while traversing
> forms but I cannot replicate the situation myself. Any knowledge of this
> will be appreciated!
>
>

--- End Message ---
--- Begin Message ---
This behavior could happen if your team is using load-balancing on multiple 
T-1s instead of a bonded connection.  That would cause them to use different 
IPs/connections, and would normally close the session.

That's a remote possibility, but that actually happened to me on one of our 
projects.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
http://www.americanstudentloan.com
1.800.575.1099

On Tuesday 31 January 2006 04:12 pm, Richard Correia wrote:
> Which php version and platform?
>
> Thanks
> Rich
>
> On 2/1/06, Dave Goodchild <[EMAIL PROTECTED]> wrote:
> > Hi all - does anyone know why, in certain cases, session variables are
> > lost
> > from the $_SESSION superglobal array? I am writing a session-driven app
> > and
> > for some reason the testing crew lose a certain variable while traversing
> > forms but I cannot replicate the situation myself. Any knowledge of this
> > will be appreciated!

--- End Message ---
--- Begin Message ---
On Tue, January 31, 2006 8:15 am, Olaf Greve wrote:
>               header("Content-Encoding: ".$Encoding);
>               echo "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xFF";

I don't know diddly about gzip-encoding and browsers, but this line
looks pretty hinky to me...

>               echo substr(gzcompress($Content,$level),2,-4);

I suspect it may also be that case that broken browsers are simply
lying about what kinds of compression they can handle...

Not much you can do about that...

I've got a real low trust factor in web browser software for some odd
reason... :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Tue, January 31, 2006 7:04 am, David BERCOT wrote:
> I'd like to connect to DBase files (.dbf) in order to do SQL requests.
> Do you know if it is possible ?
> If yes, do you have an example ?
> I'm working on Debian with PHP5.

http://www.php.net/dbase

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Tue, January 31, 2006 10:21 am, Russell Jones wrote:
> Any good classes or scripts out there to just clean data that will be
> placed
> into XML? I always have a problem with random "tokens" ruining XML and
> I
> would prefer if I could just find a way to clean all the junk out
> before
> putting it into an xml file.

Not an XML expert, but...

I think wrapping everything in a CDATA should be pretty safe...

You could also base64_encode (or similar) everything before you put it
into the XML, and undo that at the other end, I suppose.

I've also found that different XML engines will choke on different
things -- Firefox will complain about XML that "works" in nusoap
and/or PHP5 SOAP.

XML usually turns out to be a lot more painful than it seems like it
should, for me at least, unless the original problem was so simplistic
and trival that XMl was overkill in the first place...

YMMV

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Tue, January 31, 2006 7:46 am, Georgi Ivanov wrote:
> I'm writing a simple class. In order to be compatible with php4 and
> php5 I've
> done this :
>
> class test{
>       function Test(){
>               //This will be called in PHP4
>       }
>       function __construct(){
>               //This will be called in PHP5
>               $this->Test();
>       }
> }
>
> Is this a solution ? Is there a better way ?

I suppose if you want the code to run under PHP6, 7, 8, 9, 10, ... it
is somewhat forward-looking to the potential day when Test::Test()
might no longer work as the constructor...

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Mon, January 30, 2006 11:54 pm, Jacques wrote:
> Is it possible that the PHP engine can generate duplicate session id's
> for
> one application? Can one assume that the session id generated and
> saved in a
> database will always be unique (never to be repeated)?

I think the odds are pretty good against, but there's no guarantee of
uniqueness...

If you replace the usual 'file' session handler with 'user' you could
check for yourself easily enough, I should think...

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Mon, January 30, 2006 8:08 pm, Tod Thomas wrote:
> I just built phpV5.1.2 with the same options I used to build php4:
>
> ./configure  --prefix=/opt/php5
> --with-apxs2=/opt/apache/bin/apxs
> --with-mysql=/opt/mysql
> --disable-cgi --with-zlib
>
> After make install I had libphp5.so in the ./apache/modules directory
> as
> expected.  I commented out my LoadModule directive for php4 and
> uncommented out the directive for php5.  I copied php.ini-dist to
> /opt/php5/lib/php.ini and restarted apache.
>
> I expected the test.php page that displays the date, time and the
> output
> of phpinfo() to work.  Instead it just prints out all of the text,
> never
> interpreting the code.
>
> When I switch it back to php4 everything works fine.  Neither the
> access
> or error logs display any problems.  ldd of libphp5.so shows everthing
> as resolved.  The apache user owns that lib as well as liphp4.so so no
> problems there.  httpd -t says everthing is syntactically correct.
> I've
> really changed nothing other than the library and its name in
> httpd.conf.
>
> What else could I be doing wrong?  Is there something I can try to
> debug
> and get it to tell me what's up?

I think your add-handler would only work for PHP as CGI...

The AddType directives are frequently encased in httpd.conf in blocks
something like:
<If mod_php4.c>
  AddType application/x-httpd-php .php
</If>

That syntax is wrong, but you get the point -- If you've uncommented
the PHP4 Module, the mod_ph4.c (or whatever it is) needs to change to
5 as well, in the conditional expression that enables PHP4/PHP5.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
Hi,

How can I run non-PHP code snippets from within PHP?
For example: Is it possible to include a C++ code snippet within PHP and run it as it was a regular include? I know there's a solution using exec() and such, but I want to run the snippets like inline code.

-thanks, Eli

--- End Message ---
--- Begin Message ---
"Those aren't tables"

Doesn't matter... (to me:)


""Richard Lynch"" <[EMAIL PROTECTED]> kirjoitti 
viestissä:[EMAIL PROTECTED]
> On Thu, January 26, 2006 11:35 am, William Stokes wrote:
>> This is totally HTML question but I had to post cause I can't get this
>> one
>> to work myself....
>>
>> How to print tables to a page so that they are placed side by side
>> horizontally as long as there is screen width left and then continue
>> to
>> second row below? Like in many image galleries where thumpnails are
>> dumped
>> to screen and the lines of thumpnails scale dynamically according to
>> screen
>> widht.
>>
>> I need to dump my thumpnails to screen and add some image info below
>> every
>> thumpnail and I want to take advantage of the whole screen widht.
>
> Those aren't tables, that's CSS, almost for sure...
>
> -- 
> Like Music?
> http://l-i-e.com/artists.htm
> 

--- End Message ---

Reply via email to