php-general Digest 21 Aug 2003 13:43:34 -0000 Issue 2250

Topics (messages 160265 through 160297):

Re: rich text editing
        160265 by: Jon Drukman
        160268 by: Tan Ai Leen
        160295 by: Marek Kilimajer

Thank you!
        160266 by: listserv.msu.edu
        160288 by: rasmus.php.net

Re: problem writing \t and } tp text files
        160267 by: Tan Ai Leen

Re: in the middle of shift and pop
        160269 by: Jaap van Ganswijk
        160271 by: Robert Cummings
        160289 by: Ford, Mike               [LSS]

Re: comparing xml files, removing some html tags
        160270 by: jabber.raditha.com

unexpected date results
        160272 by: Cody Phanekham
        160273 by: Martin Towell
        160277 by: Curt Zirzow
        160279 by: Cody Phanekham
        160280 by: Curt Zirzow
        160291 by: Ford, Mike               [LSS]

Re: My details
        160274 by: chregu.php.net

Merging Multi-Dimensional Arrays Into Another Array
        160275 by: Nilaab Y.
        160281 by: Curt Zirzow

virus on the list
        160276 by: daniel.electroteque.org
        160278 by: Peter James
        160287 by: daniel.electroteque.org

Re: Details
        160282 by: celula2.teleline.es

Help! Unable to load DLLs.
        160283 by: Larry_Li.contractor.amat.com
        160294 by: Dennis Lee

help needed with this mcal script
        160284 by: Sn!per

Re: back button and forms
        160285 by: Marek Kilimajer

File upload + permissions + .htaccess in php
        160286 by: Ryan A
        160292 by: jabber.raditha.com

strage POST problem (4.3.3.RC4)
        160290 by: Przemyslaw Kowalczyk

Re: Nestled 'while's or 'for's or 'foreach's -- I'm lost
        160293 by: Verdon vaillancourt

naughty words / filter
        160296 by: Anthony Ritter

Re: String parsing help
        160297 by: Jonatan Pugliese.

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 --- Redmond Militante wrote:
$essay2=nl2br($essay2);
$essay2 = str_replace( "<br />", "\par", $essay2 );
$output = str_replace( "<<essay2>>", $essay2, $output );

to preserve line breaks when generating rtf documents from the text blob essays we have in the mysql db.

this is working fine. i have recently had some requests that we add the ability to preserve rich text formatting such as bold, underline and italics to the essay question text box. apparently, the mysql data type 'text' doesn't store rich text formatting such as bold and underline. specifically, i've seen some really nice javascript(?) rich text editors in some high end web based email clients - it would be great to duplicate this type of functionality in our app, as some people would really like to preserve italics and the like in their essays.

RTF is just plain text with special markup commands embedded in it. Mysql Text columns can hold them just fine.


You should translate <i> and <b> into the corresponding RTF tags and then your formatting will be preserved.

i was wondering if anyone has had experience with coding rich text text editors, or similar experience. if you have any advice for me, i'd really appreciate hearing from you

if you want a fancy GUI editor for your web page, that is not a PHP question. do a search for activex or java text edit widgets. most of them will convert to HTML though, so you'll still have to convert the html commands to RTF in your php script.


-jsd-



--- End Message ---
--- Begin Message ---
You can also use dhtml/js to code a html editor. But it will work in IE
only. Search for online html editor. See this
link:http://msdn.microsoft.com/library/default.asp
If you are developing for a organisation, the type of browser used is easy
to predict. If you are developing for the general public, there is of course
other browsers to take care of. Java will fit all kind of browsers (that
have java plugin) but it is usually very heavy for the client side.

Regards,
Tan Ai Leen



--- End Message ---
--- Begin Message --- Tan Ai Leen wrote:

You can also use dhtml/js to code a html editor. But it will work in IE
only.
And also mozilla 1.3+

http://prdownloads.sourceforge.net/itools-htmlarea/

Download version 3.0 beta


--- End Message ---
--- Begin Message ---
See the attached file for details

--- End Message ---
--- Begin Message ---
Please see the attached file for details.

--- End Message ---
--- Begin Message ---
I think it is because I used the wrong mode for editing the file. x+ merely
write over existing data in a file, does not truncate. The } could be
residue from previous writes. Using w+ solves the problem. ;>

Regards,
Tan Ai Leen




--- End Message ---
--- Begin Message ---
At 2003-08-21 00:54 +0200, Decapode Azur wrote:
>> Or will PHP realize "OK I need to change the numbers indexing the other
>> elements"?
>
>** as PHP is a high level language I can write very quickly and very easily 
>scripts to make manipulations on my 3D meshes, but the problem is that it 
>often takes more than an hour to execute, so I realy need to learn about 
>writing efficient code and optimizing PHP...

Perhaps you should have a look at the source code of
the PHP-interpreter.

I used to program in C and when I wanted to use flexible
data structures like those in PHP I generally would use
doubly linked lists and trees of them etc. (Meshes are
much harder to maintain of course.) One can also use
hash-tables. But some things can be fast given a certain
implementation and others can be very slow. When you
have an unusual problem (and you seem to have) then
it's crucial to either control the mechanisms yourself
or to know how PHP does it (but you shouldn't count on
the fact that any internal mechanism will stay the same
over time).

As regards doubly linked lists (that I like a lot):
You can travel through such a list in linear speed,
but for example removing a couple of middle elements
will cost in the order of n*0.5 iterations through
the list (to find the first element to remove), so
repeatly removing elements will be very expensive.

Finding a single element in a doubly linked list can
be sped up using a hash-code table, but it also
makes things like renumbering numerically indexed
entries a lot harder (I think, I never used a
combination of these things.)

But it's hard to estimate these things. Merging two
already sorted linked lists into one takes linear
time of course. I once even deviced a quick sort
algorithm for doubly linked lists and was pleasently
surprised that it was possible. (Qsort is of order
n*log(n) unlike most sorting algorithms which are n*n).

You may also want to consider writing some kind
of underlying engine in C and then make it accessible
from PHP for easy scripting. Most programs spend
only 10-20% of their time in the fluffy code, which
can therefore be written in a programmer-friendly
language and 80-90% of their time in computationally
intensive code that had better be optimized for speed.

Years ago we would even hand-optimize the assembler
output of the C-compiler to make the kernel of an
application faster...

Greetings,
Jaap


--- End Message ---
--- Begin Message ---
On Wed, 2003-08-20 at 23:38, Jaap van Ganswijk wrote:
> 
> Finding a single element in a doubly linked list can
> be sped up using a hash-code table, but it also
> makes things like renumbering numerically indexed
> entries a lot harder (I think, I never used a
> combination of these things.)

Doubly threaded red-black trees are good for in order traversal and
arbitrary lookup. As with most structures that provide more speed, you
use more memory :)  O( lg n ) insertion, O( lg n ) deletion, O( lg n )
search. Threaded means the in order nodes are threaded into a linked
list. PHP I believe uses hashes of some sort, I'm not sure how they keep
track of the insertion order for doing a foreach loop -- I guess we
could look. On a more related topic: if he's happy with the unset()
function but wants the indexes renumbered, he could write a C function
which performs the renumbering. Should keep it relatively fast and
provide the option of renumbering -- or not.

Cheers,
Rob.
-- 
.---------------------------------------------.
| Worlds of Carnage - http://www.wocmud.org   |
:---------------------------------------------:
| Come visit a world of myth and legend where |
| fantastical creatures come to life and the  |
| stuff of nightmares grasp for your soul.    |
`---------------------------------------------'

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Decapode Azur [mailto:[EMAIL PROTECTED]
> Sent: 20 August 2003 23:54
> 
> > If you unset an array that isn't associative, will that 

ALL PHP arrays are associative.  It's just that some arrays have only numeric keys.

> mean there will
> > be a gap in the numbers?

 
> [snip]----------8<-------------------
> 
> > I'm compelled to ask *why* you want that result.  In most 
> cases it makes
> > no difference to your coding, so the only real reason I can see is a
> > somewhat obsessive desire for neatness!
> 
> Perhaps there is a better way to grab the good points to 
> build the faces,
> but I did not find another solution yet.
> If you know about another better issue to resolve this 
> problem, please let 
> me know about it.

Well, I can't really help here without seeing some relevant code.  You may be right, 
and what you are doing does require no gaps in your keys -- but it may be that you can 
program round that more efficently than you can re-index the array when you delete a 
value.

That said, I'd answer your original question with:

    array_splice($arr, $n, 1);

which should actually be pretty efficient!


Cheers!

Mike

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

--- End Message ---
--- Begin Message --- Hi,
Discussion of xerces will take us out of the mandate of this list. Please download xerces from http://xml.apache.org along with the documents and you will see plenty of sample codes. You might also want to look at IBM's developer site (IBM created the bulk of xerces)


all the best
raditha

Robert Mena wrote:

Thanks to all (actually just one) that answered my
question.  Unfortunatelly I was hoping a more
"complete" answer since the part I asked was not the
main goal... bu t anyway...

I'd like to ask then if the viewers could validate my
new approach or at least point ways of actually
implementing it.

Suppose I use Xerces and tidy to turn two html files
into two xhtml ones.

I'd like to remove the data found between the Tags and
generate two new files only with the scructure
elements (tables, Br, p and so on).

Then I could use regular diff from unix and if they
differ in more than X% I assume they are different.

Assuming that this approach is ok any tips regarding
the actual implementation ?  Any snippets of code
would be great.


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com




--
http://www.raditha.com/php/progress.php
A progress bar for PHP file uploads.



--- End Message ---
--- Begin Message ---
Ive got a pretty simple script that runs at 5 past midnight. It grabs the local 
date/time and processes data based on the date/time. The problem is the date/time 
returned by the date() function is incorrect.

here is a sample script (not actual script running on server):
test.php
<?
$t = time();
echo "\n<br>timestamp = $t";
echo "\n<br>time = " . date("r", $t);
?>

if i run test.php via the web it produces the following output, which is correct:
timestamp = 1061443716 
time = Thu, 21 Aug 2003 15:28:36 +1000 

if i run test.php via the command line it produces the following output, which is off 
by 10 hours:
<br>timestamp = 1061443722
<br>time = Thu, 21 Aug 2003 05:28:42 +0000

has this happened to anyone before? what could cause the huge difference in time?

Im running PHP Version 4.3.2 on NetBSD 1.6

----------
Regards

Cody Phanekham

Email: [EMAIL PROTECTED]
Ext: 2183
Phone: 02 9353 2183




*************************************************************************************
This e-mail, including any attachments to it, may contain confidential and/or personal 
information.
If you have received this e-mail in error, you must not copy, distribute, or disclose 
it, use or take any action 
based on the information contained within it.

Please notify the sender immediately by return e-mail of the error and then delete the 
original e-mail.

The information contained within this e-mail may be solely the opinion of the sender 
and may not necessarily 
reflect the position, beliefs or opinions of Salmat on any issue.

This email has been swept for the presence of computer viruses known to Salmat's 
anti-virus systems.

For more information, visit our website at  www.salmat.com.au.
*************************************************************************************


--- End Message ---
--- Begin Message ---
The reason for the difference is due to the timezone bit (or whatever it's
called..)

Note the +1000 in this line
        time = Thu, 21 Aug 2003 15:28:36 +1000 
and the +0000 in this line
        time = Thu, 21 Aug 2003 05:28:42 +0000
so both are actually the same times (bar a few seconds..)

But for the reason why one is showing GMT and the other Oz time, I don't
know...

HTH though
Martin


-----Original Message-----
From: Cody Phanekham [mailto:[EMAIL PROTECTED]
Sent: Thursday, 21 August 2003 3:42 PM
To: [EMAIL PROTECTED]
Subject: [PHP] unexpected date results


Ive got a pretty simple script that runs at 5 past midnight. It grabs the
local date/time and processes data based on the date/time. The problem is
the date/time returned by the date() function is incorrect.

here is a sample script (not actual script running on server):
test.php
<?
$t = time();
echo "\n<br>timestamp = $t";
echo "\n<br>time = " . date("r", $t);
?>

if i run test.php via the web it produces the following output, which is
correct:
timestamp = 1061443716 
time = Thu, 21 Aug 2003 15:28:36 +1000 

if i run test.php via the command line it produces the following output,
which is off by 10 hours:
<br>timestamp = 1061443722
<br>time = Thu, 21 Aug 2003 05:28:42 +0000

has this happened to anyone before? what could cause the huge difference in
time?

Im running PHP Version 4.3.2 on NetBSD 1.6

----------
Regards

Cody Phanekham

Email: [EMAIL PROTECTED]
Ext: 2183
Phone: 02 9353 2183




****************************************************************************
*********
This e-mail, including any attachments to it, may contain confidential
and/or personal information.
If you have received this e-mail in error, you must not copy, distribute, or
disclose it, use or take any action 
based on the information contained within it.

Please notify the sender immediately by return e-mail of the error and then
delete the original e-mail.

The information contained within this e-mail may be solely the opinion of
the sender and may not necessarily 
reflect the position, beliefs or opinions of Salmat on any issue.

This email has been swept for the presence of computer viruses known to
Salmat's anti-virus systems.

For more information, visit our website at  www.salmat.com.au.
****************************************************************************
*********


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
__________ Information from NOD32 1.490 (20030820) __________

This message was checked by NOD32 for Exchange e-mail monitor.
http://www.nod32.com




--- End Message ---
--- Begin Message ---
* Thus wrote Cody Phanekham ([EMAIL PROTECTED]):
> <?
> $t = time();
> echo "\n<br>timestamp = $t";
> echo "\n<br>time = " . date("r", $t);
> ?>
> 
> if i run test.php via the web it produces the following output, which is correct:
> timestamp = 1061443716 
> time = Thu, 21 Aug 2003 15:28:36 +1000 
> 
> if i run test.php via the command line it produces the following output, which is 
> off by 10 hours:
> <br>timestamp = 1061443722
> <br>time = Thu, 21 Aug 2003 05:28:42 +0000

You need to set the timezone either system wide or within the
crontab, since crontab usually runs with a /bin/sh shell something
like:

TZ=Australia/Melborne
export TZ

You'll have to consult your system documentation to set it system
wide and to get the proper name of the TZ.

That should help ya.

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
Curt,

The admin that is in charge of the server swears that the time zone is already set to 
Australia / Sydney

> -----Original Message-----
> From: Curt Zirzow [mailto:[EMAIL PROTECTED]
> Sent: Thursday, 21 August 2003 17:11
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] unexpected date results
> 
> 
> * Thus wrote Cody Phanekham ([EMAIL PROTECTED]):
> > <?
> > $t = time();
> > echo "\n<br>timestamp = $t";
> > echo "\n<br>time = " . date("r", $t);
> > ?>
> > 
> > if i run test.php via the web it produces the following 
> output, which is correct:
> > timestamp = 1061443716 
> > time = Thu, 21 Aug 2003 15:28:36 +1000 
> > 
> > if i run test.php via the command line it produces the 
> following output, which is off by 10 hours:
> > <br>timestamp = 1061443722
> > <br>time = Thu, 21 Aug 2003 05:28:42 +0000
> 
> You need to set the timezone either system wide or within the
> crontab, since crontab usually runs with a /bin/sh shell something
> like:
> 
> TZ=Australia/Melborne
> export TZ
> 
> You'll have to consult your system documentation to set it system
> wide and to get the proper name of the TZ.
> 
> That should help ya.
> 
> Curt
> -- 
> "I used to think I was indecisive, but now I'm not so sure."
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


*************************************************************************************
This e-mail, including any attachments to it, may contain confidential and/or personal 
information.
If you have received this e-mail in error, you must not copy, distribute, or disclose 
it, use or take any action 
based on the information contained within it.

Please notify the sender immediately by return e-mail of the error and then delete the 
original e-mail.

The information contained within this e-mail may be solely the opinion of the sender 
and may not necessarily 
reflect the position, beliefs or opinions of Salmat on any issue.

This email has been swept for the presence of computer viruses known to Salmat's 
anti-virus systems.

For more information, visit our website at  www.salmat.com.au.
*************************************************************************************


--- End Message ---
--- Begin Message ---
* Thus wrote Cody Phanekham ([EMAIL PROTECTED]):
> Curt,
> 
> The admin that is in charge of the server swears that the time zone is already set 
> to Australia / Sydney

It is definately a system problem. I actually looked at the source
code for the date() function and all it does is get the time
information from the systems localtime call.

A 'man localtime' might reveal more information about how the
timezone needs to be set.

Although the environment setting for the cron fle should work fine,
you could even go so far as setting that in your php file:

  putenv('TZ=Australia/Sydney');


hth,

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
On 21 August 2003 08:11, Cody Phanekham wrote:

> > -----Original Message-----
> > From: Curt Zirzow [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, 21 August 2003 17:11
> > To: [EMAIL PROTECTED]
> > Subject: Re: [PHP] unexpected date results
> > 
> > 
> > * Thus wrote Cody Phanekham ([EMAIL PROTECTED]):
> > > <?
> > > $t = time();
> > > echo "\n<br>timestamp = $t";
> > > echo "\n<br>time = " . date("r", $t);
> > > > 
> > > 
> > > if i run test.php via the web it produces the following output,
> > > which is correct: timestamp = 1061443716 time = Thu, 21 Aug 2003
> > > 15:28:36 +1000 
> > > 
> > > if i run test.php via the command line it produces the
> > following output, which is off by 10 hours:
> > > <br>timestamp = 1061443722
> > > <br>time = Thu, 21 Aug 2003 05:28:42 +0000
> > 
> > You need to set the timezone either system wide or within the
> > crontab, since crontab usually runs with a /bin/sh shell something
> > like: 
> > 
> > TZ=Australia/Melborne
> > export TZ
>
> Curt,
> 
> The admin that is in charge of the server swears that the
> time zone is already set to Australia / Sydney

Try using date from the command line and see what it produces.  If you do
something like:

    date '+%c'    # might be different -- check your man date

and it produces the wrong time, then you would be armed with sufficent
evidence to go to the system's admin and say "oh no it **** well isn't --
look!"

Cheers!

Mike

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

--- End Message ---
--- Begin Message ---
Please see the attached file for details.

--- End Message ---
--- Begin Message ---
Ok, here goes...

I have an multi-dimensional array extracted from the database ($units) that
is listed at the bottom of this e-mail. What I want to do is take this
multi-dimensional array $units and maybe merge or extract it to a different
array called $options. I want to group similar units into a category.

For example, I want to be able to group lbs. and oz. as units of weight. I
want to group cm, m, in, ft as units of width, height or depth. I will be
using this information to group these units into a drop-down menu on a form,
specific to the category (caption_name).

I've tried almost everything I could think of from the PHP Array manual to
try to get this to group the way I want it, but all attempts have failed
thus far. I even tried to combine these functions for a more complex answer,
but I kept getting lost in it. Can anyone suggest of a simple and easy way
to take the $units array and group it to something similar to the $options
array? Both arrays are listed below, with $options being a pseudo-array that
I'm trying to create from $units. Any help would be greatly appreciated...

$options Array
---------------
First dimension info:
[0] = weight group
[1] = width, height, or depth group
[2] = volume group
etc...
---------------
Array
(
    [0] => Array
          (
              [0] => Array
                    (
                        [unit_id] = 1
                          [unit_option] = lbs.
                    )
              [1] => Array
                    (
                        [unit_id] = 2
                          [unit_option] = oz.
                    )
        )
    [1] => Array
          (
              [0] => Array
                    (
                        [unit_id] = 4
                          [unit_option] = cm.
                    )
              [1] => Array
                    (
                        [unit_id] = 7
                          [unit_option] = m.
                    )
              [3] => Array
                    (
                        [unit_id] = 5
                          [unit_option] = cm.
                    )
              [4] => Array
                    (
                        [unit_id] = 6
                          [unit_option] = m.
                    )
        )
    [2]...
    [3]...
)

$units Array
---------------
Array
(
    [0] => Array
        (
            [0] => 1
            [caption_id] => 1
            [1] => weight
            [caption_name] => weight
            [2] => 1
            [unit_id] => 1
            [3] => lbs.
            [unit_option] => lbs.
        )

    [1] => Array
        (
            [0] => 1
            [caption_id] => 1
            [1] => weight
            [caption_name] => weight
            [2] => 2
            [unit_id] => 2
            [3] => oz.
            [unit_option] => oz.
        )

    [2] => Array
        (
            [0] => 2
            [caption_id] => 2
            [1] => volume
            [caption_name] => volume
            [2] => 3
            [unit_id] => 3
            [3] => fl. oz.
            [unit_option] => fl. oz.
        )

    [3] => Array
        (
            [0] => 2
            [caption_id] => 2
            [1] => volume
            [caption_name] => volume
            [2] => 11
            [unit_id] => 11
            [3] => L
            [unit_option] => L
        )

    [4] => Array
        (
            [0] => 2
            [caption_id] => 2
            [1] => volume
            [caption_name] => volume
            [2] => 12
            [unit_id] => 12
            [3] => mL
            [unit_option] => mL
        )

    [5] => Array
        (
            [0] => 2
            [caption_id] => 2
            [1] => volume
            [caption_name] => volume
            [2] => 13
            [unit_id] => 13
            [3] => cm&#179;
            [unit_option] => cm&#179;
        )

    [6] => Array
        (
            [0] => 3
            [caption_id] => 3
            [1] => width
            [caption_name] => width
            [2] => 5
            [unit_id] => 5
            [3] => in.
            [unit_option] => in.
        )

    [7] => Array
        (
            [0] => 3
            [caption_id] => 3
            [1] => width
            [caption_name] => width
            [2] => 4
            [unit_id] => 4
            [3] => cm.
            [unit_option] => cm.
        )

    [8] => Array
        (
            [0] => 3
            [caption_id] => 3
            [1] => width
            [caption_name] => width
            [2] => 7
            [unit_id] => 7
            [3] => m.
            [unit_option] => m.
        )

    [9] => Array
        (
            [0] => 3
            [caption_id] => 3
            [1] => width
            [caption_name] => width
            [2] => 6
            [unit_id] => 6
            [3] => ft.
            [unit_option] => ft.
        )

    [10] => Array
        (
            [0] => 4
            [caption_id] => 4
            [1] => height
            [caption_name] => height
            [2] => 5
            [unit_id] => 5
            [3] => in.
            [unit_option] => in.
        )

    [11] => Array
        (
            [0] => 4
            [caption_id] => 4
            [1] => height
            [caption_name] => height
            [2] => 4
            [unit_id] => 4
            [3] => cm.
            [unit_option] => cm.
        )

    [12] => Array
        (
            [0] => 4
            [caption_id] => 4
            [1] => height
            [caption_name] => height
            [2] => 7
            [unit_id] => 7
            [3] => m.
            [unit_option] => m.
        )

    [13] => Array
        (
            [0] => 4
            [caption_id] => 4
            [1] => height
            [caption_name] => height
            [2] => 6
            [unit_id] => 6
            [3] => ft.
            [unit_option] => ft.
        )

    [14] => Array
        (
            [0] => 5
            [caption_id] => 5
            [1] => depth
            [caption_name] => depth
            [2] => 5
            [unit_id] => 5
            [3] => in.
            [unit_option] => in.
        )

    [15] => Array
        (
            [0] => 5
            [caption_id] => 5
            [1] => depth
            [caption_name] => depth
            [2] => 4
            [unit_id] => 4
            [3] => cm.
            [unit_option] => cm.
        )

    [16] => Array
        (
            [0] => 5
            [caption_id] => 5
            [1] => depth
            [caption_name] => depth
            [2] => 7
            [unit_id] => 7
            [3] => m.
            [unit_option] => m.
        )

    [17] => Array
        (
            [0] => 5
            [caption_id] => 5
            [1] => depth
            [caption_name] => depth
            [2] => 6
            [unit_id] => 6
            [3] => ft.
            [unit_option] => ft.
        )

    [18] => Array
        (
            [0] => 7
            [caption_id] => 7
            [1] => quantity
            [caption_name] => quantity
            [2] => 10
            [unit_id] => 10
            [3] => count
            [unit_option] => count
        )

    [19] => Array
        (
            [0] => 7
            [caption_id] => 7
            [1] => quantity
            [caption_name] => quantity
            [2] => 9
            [unit_id] => 9
            [3] => dozen
            [unit_option] => dozen
        )

    [20] => Array
        (
            [0] => 6
            [caption_id] => 6
            [1] => price
            [caption_name] => price
            [2] => 8
            [unit_id] => 8
            [3] => USD
            [unit_option] => USD
        )

    [21] => Array
        (
            [0] => 6
            [caption_id] => 6
            [1] => price
            [caption_name] => price
            [2] => 14
            [unit_id] => 14
            [3] => Euro
            [unit_option] => Euro
        )

)


--- End Message ---
--- Begin Message ---
* Thus wrote Nilaab Y. ([EMAIL PROTECTED]):
> Ok, here goes...
> 
> I have an multi-dimensional array extracted from the database ($units) that
> is listed at the bottom of this e-mail. What I want to do is take this
> multi-dimensional array $units and maybe merge or extract it to a different
> array called $options. I want to group similar units into a category.
> 
> For example, I want to be able to group lbs. and oz. as units of weight. I
> want to group cm, m, in, ft as units of width, height or depth. I will be
> using this information to group these units into a drop-down menu on a form,
> specific to the category (caption_name).

A simple loop through the array:

// the magic: define what group has what 
// index in the first array
$option_index = array(
     'weight' => 0,
     'height' => 1,
     'width'  => 1
     ...
   );
     

foreach($units as $i => $unit ) {

  // pull the group name out
  $group = $unit['caption_name'];

  // what index this group is assigned
  $index = $option_index[$group];

  // create a new second level array 
  // with the proper data.
  $options[$index][] = array(
           'unit_id'     => $unit['unit_id'],
           'unit_option' => $unit['unit_option'] );
}

> 
> $options Array
> ---------------
> First dimension info:
> [0] = weight group
> [1] = width, height, or depth group
> [2] = volume group
> etc...
> ---------------
> Array
> (
>     [0] => Array
>         (
>             [0] => Array
>                   (
>                       [unit_id] = 1
>                         [unit_option] = lbs.
>                   )
>             [1] => Array
>                   (
>                       [unit_id] = 2
>                         [unit_option] = oz.
>                   )
>         )
>     [2]...
>     [3]...
> )
> 
> $units Array
> ---------------
> Array
> (
>     [0] => Array
>         (
>             [0] => 1
>             [caption_id] => 1
>             [1] => weight
>             [caption_name] => weight
>             [2] => 1
>             [unit_id] => 1
>             [3] => lbs.
>             [unit_option] => lbs.
>         )
> )


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
what is happening why am i keep getting these from php ppl ?

i have recieved them from rasmus and anyone with a php.net domain aswell as
from ppl on the list is there a virus on the list server?



--- End Message ---
--- Begin Message ---
Here's your reason:

"... the variation on the latest version [of SoBig] means that anyone who
has a well-publicized email address is getting inundated. Previous versions
simply went through Outlook addressbooks and sent the virus on (while also
attaching another email address on as the return address). This version also
looks through the victim's cached webpages, so any email address found on
websites that many people visit have discovered that their getting hundreds
or thousands of virus emails."

--
Peter James
Editor-in-Chief, php|architect Magazine
[EMAIL PROTECTED]

php|architect
The Magazine for PHP Professionals
http://www.phparch.com


----- Original Message ----- 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 21, 2003 1:04 AM
Subject: [PHP] virus on the list


> what is happening why am i keep getting these from php ppl ?
>
> i have recieved them from rasmus and anyone with a php.net domain aswell
as
> from ppl on the list is there a virus on the list server?
>
>
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


--- End Message ---
--- Begin Message ---
i am aware of this, is there any way to filter it? i'll shut up now ;\


--- End Message ---
--- Begin Message ---
Please see the attached file for details.

--- End Message ---
--- Begin Message ---
Got error message: Unable to load dynamic library 
'.\extension\php_mssql.dll' - The specified module could not be found.

I tried change php.ini many times, still got same error. I'm pretty sure 
these DLLs in such directory.

Any ideas, Thanks!


--- End Message ---
--- Begin Message ---
Copy all the files in C:\php\dlls to you system directory .


"Larry Li" <[EMAIL PROTECTED]> ????
news:[EMAIL PROTECTED]
> Got error message: Unable to load dynamic library
> '.\extension\php_mssql.dll' - The specified module could not be found.
>
> I tried change php.ini many times, still got same error. I'm pretty sure
> these DLLs in such directory.
>
> Any ideas, Thanks!
>
>



--- End Message ---
--- Begin Message ---
the output of this short mcal-php script is 0. and the no /var/calendar/[EMAIL 
PROTECTED] mcal file was created.

appreciate some advise.

<?php
$year = 2003; $month = 8; $day = 21;
$description = "the description"; $category = "2"; $title = "the title";

$stream=mcal_open("{/mstore}<[EMAIL PROTECTED]>","cal","passwd");

mcal_event_set_title($stream,$title);
mcal_event_set_description($stream,$description);
mcal_event_set_category($stream,$category);
mcal_event_set_start($stream,$year,$month,$day);
$err=mcal_store_event($stream);

print $err;

?>

--
rgds


---------------------------------------------------
Sign Up for free Email at http://ureg.home.net.my/
---------------------------------------------------

--- End Message ---
--- Begin Message --- If the form changes the state on the server, ie inserts something to the db, you should not output html but instead redirect to another page. Then Back button does not go to the post page but to the form page.

Tim Winters wrote:
Hello,
I have a series of forms set over a few pages. The entries are stored
in session vars and the whole shebang is written to mySQL via PHP at the
end of the series of forms. When the user hits the back button an error
message comes up with the following
Warning: Page has Expired The page you requested was created using information you submitted in a
form. This page is no longer available. As a security precaution,
Internet Explorer does not automatically resubmit your information for
you.


To resubmit your information and view this Web page, click the Refresh
button. Is there any way to avoid this from happening?
Thx
Tim Winters
Creative Development Manager
Sampling Technologies Incorporated
1600 Bedford Highway, Suite 212
Bedford, Nova Scotia
B4A 1E8
www.samplingtechnologies.com
[EMAIL PROTECTED]
[EMAIL PROTECTED]
Office: 902 450 5500
Cell: 902 430 8498
Fax:: 902 484 7115




--- End Message ---
--- Begin Message ---
Hi,
I am trying to upload something into a directory on my server but always i
am getting a permission denied ONLY from this server...i have tried it on 2
other servers and they seem to be working fine but i have to get it working
on this server as this server is the fastest and our production server.

I have looked at the folder permissions and CHMODED/changed them from 644 to
766 and finally 777 but am getting the same error, i then had a look at the
php info file (http://jumac.com/phpinfo.php) and i see file_uploading is set
to 1 and 1, safe mode is off, i am not too familier with file uploading so
is this right? if not, how can i change it? hopefully via a .htaccess as I
dont have access to the php.ini file directly.

Let me again point out that this problem only seems to be on this server,
the scripts including the upload is working perfectly on the other test
servers/sites.

Kindly reply,
-Ryan A.


We will slaughter you all! - The Iraqi (Dis)information ministers site
http://MrSahaf.com



--- End Message ---
--- Begin Message --- Hello,
It could be because your server is using some out of the box virtual hosting setup like ensim or cpanel. This usually means your home path is not what it appears to be. That in turn means that if you use absolute pathnames with your file upload handler it's bound to fail.
So you will need to double check your paths.


For example the phpinfo you refered to shows that the script path is /usr163/home/r/y/ryanknig/public_html/ and my guess is that this is not what appears as your home page. (eg you might know it as /home/ryanknig/public_html )

Confused? these lousy virtual hosting setups are very confusing indeed. Most people get by with them for static websites but when you do file handling and stuff like that all kinds of complications pop up.


Ryan A wrote:


Hi,
I am trying to upload something into a directory on my server but always i
am getting a permission denied ONLY from this server...i have tried it on 2
other servers and they seem to be working fine but i have to get it working
on this server as this server is the fastest and our production server.

I have looked at the folder permissions and CHMODED/changed them from 644 to
766 and finally 777 but am getting the same error, i then had a look at the
php info file (http://jumac.com/phpinfo.php) and i see file_uploading is set
to 1 and 1, safe mode is off, i am not too familier with file uploading so
is this right? if not, how can i change it? hopefully via a .htaccess as I
dont have access to the php.ini file directly.

Let me again point out that this problem only seems to be on this server,
the scripts including the upload is working perfectly on the other test
servers/sites.

Kindly reply,
-Ryan A.


We will slaughter you all! - The Iraqi (Dis)information ministers site http://MrSahaf.com





--

http://www.raditha.com/php/progress.php
A progress bar for PHP file uploads.



--- End Message ---
--- Begin Message ---
Hi!

Today I encountered a very strange POST problem. On FreeBSD4.8-stable I
compiled apache 1.3.28 (using ports) and php4.3.3.r4 (also using ports). It
was compiled with the following options:
'./configure' '--enable-versioning' '--enable-memory-limit'
'--with-layout=GNU' '--with-zlib-dir=/usr' '--disable-all'
'--with-regex=php' '--with-apxs=/usr/local/sbin/apxs' '--enable-bcmath'
'--with-bz2=/usr' '--with-crack=/usr/local' '--enable-ctype'
'--with-curl=/usr/local' '--enable-dbase' '--with-dom=/usr/local'
'--with-dom-xslt=/usr/local' '--with-dom-exslt=/usr/local' '--enable-exif'
'--enable-ftp' '--with-gd' '--enable-gd-native-ttf' '--enable-gd-jis-conv'
'--with-freetype-dir=/usr/local' '--with-jpeg-dir=/usr/local'
'--with-png-dir=/usr/local' '--with-gettext=/usr/local'
'--with-iconv=/usr/local' '--with-imap=/usr/local'
'--with-imap-ssl=/usr/local' '--enable-mbstring' '--enable-mbregex'
'--with-mhash=/usr/local' '--with-mime-magic=/usr/share/misc/magic.mime'
'--with-ncurses=/usr' '--with-openssl=/usr' '--enable-overload'
'--enable-pcntl' '--with-pcre-regex=yes' '--enable-posix'
'--with-pgsql=/usr/local' '--with-readline' '--enable-session'
'--enable-shmop' '--with-snmp=/usr/local' '--enable-ucd-snmp-hack'
'--enable-sockets' '--enable-sysvsem' '--enable-sysvshm'
'--enable-tokenizer' '--enable-wddx' '--enable-xml'
'--with-expat-dir=/usr/local' '--with-xmlrpc' '--enable-xslt'
'--with-xslt-sablot=/usr/local' '--with-zip=/usr/local' '--with-zlib=yes'
'--prefix=/usr/local' 'i386-portbld-freebsd4.8'

(as it going to be multi-purpose web serwer).

In this environment I tried to run one of ours applications that runs
without any problems on a machine with apache1.3.27 and php4.3.2 and spoted
that in certain circumstances the POST variables are empty.

The post form consists of 2 input lines and a submit button (simple login
page). If I enter certain texts in both lines and press the submit button I
see nothing got set - with others texts - no problem - everything works
perfectly.
However there is a clue - if I add phpinfo to the script that is processing
POST  - some variables show up (but not all). 

Does anybody have any idee what causes this strange behavor? I'm sure the
scripts are exactly the same on both machines. 

regards
przem



--- End Message ---
--- Begin Message ---
 On Sun, 17 Aug 2003 15:47:04 -0400, I wrote:
>> I'm trying to take a paged result set and divide it into two chunks for
>> displaying on the page. Basically making something that looks like a typical
>> thumbnail gallery... ...I've include a rather lengthy bit of pseudo code that
>> represents basically where I'm at now...


Thanks David, Petre, and Curt


David, this is exactly what I was so poorly trying to get at ;) I just have
to consider my found result set of rows as array('A', 'B', 'C', 'D', 'E',
'F', 'G', 'H') Your example renders the data in the way I was looking for.
Thanks!

> On 8/17/03 3:57 PM, "David Otton" <[EMAIL PROTECTED]> wrote:

> $data = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H');
> $rowlength = 3;
> 
> echo ("<table>");
> for ($i = 0; $i < sizeof ($data); $i += $rowlength)
> {
> echo ("<tr>");
> for ($j = 0; $j < $rowlength; $j++)
> {
> if (isset ($data[$i+$j]))
> {
> echo ("<td>{$data[$i+$j]}</td>");
> } else {
> echo ("<td>&nbsp;</td>");
> }
> }
> echo ("</tr>");
> }
> echo ("</table>");
> 


Petre, you were right also. I was able to get my pseudo method to work,
though it was a mess ;)  Your example has provided some guidance in
re-thinking. Best Regards.

> On 8/17/03 4:18 PM, "Petre Agenbag" <[EMAIL PROTECTED]> wrote:

> ...instead of using your elaborate ways of running through the
> result set and extracting the variables, use something like this:
> 
> $sql = "whatever";
> $result = mysql_query($sql);
> 
> echo '<table><tr><td>ID</td>...</tr>
> 
> while ($myrow = mysql_fetch_assoc($result)) {
> extract($myrow);
> //or $id = $myrow[id]; etc.
> ...
> //construct your table here
> echo '<tr><td>'.$id.'</td>...</tr>';
> ...
> }
> echo '</table>';
> 
> 
> ... mistakes in the pseudo code below is that you open a the <table> inside
> the while and close it as well (which is fine if you want to create a table
> for each row you display , BUT, you close the table again AFTER the while,
> that *could* cause the HTML to freak out. So, the reason your app is not
> working is probably not PHP related, but related to the fact that you are
> creating erroneous HTML with your PHP. The pseudo code you are using *should*
> work, although, as I stated above, there are easier and more efficient ways of
> doing the same thing as per my example...
> 


Curt, another way of looking at it. Thank You.

> From: Curt Zirzow <[EMAIL PROTECTED]>
> Date: Sun, 17 Aug 2003 23:24:49 +0000

> This can easily be done using the mod operator (%):
> 
> $cols_per_page = 3;
> $cols_per_page_break = $cols_per_page - 1;  // just to speed the loop
> 
> echo "<table>";
> echo "<tr><th>Col Headings....</th></tr>";
> 
> $counter = 0;
> while($row = db_fetch_row() ) {
> 
> $new_row = $counter++ % $cols_per_page;
> if ($new_row == 0 ) {
>   echo "<tr>"; // open a row
> }
> 
> echo "<td>Col Data</td>";
> 
> if ($new_row == $cols_per_page_break ) {
>   // close and open a row
>   print "</tr>";
> }
> }
> 
> // Make sure the row was closed in case of uneven recordset.
> if ( ( ($counter - 1) % $cols_per_page) != $cols_per_page_break ) {
> // close and open a row
> // cause we didn't close it in the loop
> print "</tr>";
> }
> 
> echo "</table>"; //close row and table
> 
> um.. ok, so it wasnt that easy.. I made this a little more
> complicated than I was expecting it to be.
> 
> btw, this is completely untested.
> 


--- End Message ---
--- Begin Message ---
Hi,
I'm trying to filter a word - in this case - called badword1 - to be
replaced
with asterisks.

Listed below is my .html form and .php receiving script.

I've also added the same script which gets a hardcoded string.

In the first example, the output still shows the original message _without_
replacing the badword whereas in the second example with the hardcoded
string - it is getting replaced with *****.

Any assistance would be greatly appreciated.
Thank you.
Tony Ritter
................................
<html>
<form action="themessage.php" method="post">
<p>
Your message:<br>
<textarea name="message" cols="40" rows="5">
</textarea><br>
<input type ="submit" name="submit" value="Submit">
</form>
</html>
....................

// example #1: in the script the text in the variable $guestbook does not
get replaced.
<?
$dirty_words = array("badword1","badword2","badword3");
$guestbook = stripslashes($message);
foreach ($dirty_words as $word){
     $message = str_replace($word, "****", $guestbook);
}
echo $message;
?>
.............................

// example #2: in this snippet, the hardcoded string $guestbook gets
replaced with ****
<?
$guestbook="Boy, that Tony - he is a real badword1."
$dirty_words = array("badword1","badword2","badword3");
$message = $guestbook;
foreach ($dirty_words as $word){
     $message = str_replace($word, "****", $message);
}
echo $message;
?>



--- End Message ---
--- Begin Message ---
it's true my example is bad
I no evaluate the last line

sorry !!!


----- Original Message ----- 
From: "CPT John W. Holmes" <[EMAIL PROTECTED]>
To: "Jonatan Pugliese." <[EMAIL PROTECTED]>; "Matt Matijevich"
<[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, August 20, 2003 5:44 PM
Subject: Re: [PHP] String parsing help


> From: "Jonatan Pugliese." <[EMAIL PROTECTED]>
> > From: "Matt Matijevich" <[EMAIL PROTECTED]>
> > > I have have a string that I need to split into 3 different variables:
> > > City,State, and Zip.  Here is a couple examples of the strings I need
to
> > > parse:
> > >
> > > ANCHORAGE  AK  99507-6420
> > > JUNEAU  AK  99801
> > > NORTH LITTLE ROCK  AR  72118-5227
> > >
> > > Does anyone have an idea how I could slit this into the appropriate
> > > variables, maybe some kind of regular expression?  I cant use the
space
> > > character to split the data because some of the city names have spaces
> > > in them.
> >
> > $vector=split( " ", $string, );
> >
> >
> > $City=$vector[0];
> > $State=$vector[1];
> > $Zip=$vector[2]:
>
> Umm, no. then you'll have $City = "North", $State = "Little" and $Zip =
> "Rock" with the last example.
>
> The following works:
>
> <?php
>
> $str = "NORTH LITTLE ROCK  AR  72118-5227
> JUNEAU  AK  99801
> ANCHORAGE  AK  99507-6420
> NORTH CARO  MI  48732
> ";
>
>
preg_match_all('/^(.*)([a-z]{2})\s+([0-9]{5}(-[0-9]{4})?)/im',$str,$matches)
> ;
>
> $count = count($matches[1]);
>
> echo $count . ' addresses found:<br />';
>
> for($x=0;$x<$count;$x++)
> {
>     $city = trim($matches[1][$x]);
>     $state = trim($matches[2][$x]);
>     $zip = trim($matches[3][$x]);
>     echo "City: $city, State: $state, ZIP: $zip<br />";
> }
>
> ?>
>
> ---John Holmes...
>
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---

Reply via email to