php-general Digest 14 May 2007 23:20:08 -0000 Issue 4791

Topics (messages 254914 through 254927):

printing out this nested array
        254914 by: Don Don
        254915 by: Crayon Shin Chan
        254916 by: Richard Davey
        254918 by: Don Don
        254920 by: Brad Fuller
        254921 by: Jim Lucas
        254922 by: Myron Turner
        254923 by: Richard Davey

Re: Making code public -- What steps to take? GPL?
        254917 by: Crayon Shin Chan

Re: escapeshellarg
        254919 by: Brad Fuller

Reading & Writing XML Documents...
        254924 by: Anthony J. Maske
        254925 by: Jim Moseby
        254926 by: WeberSites LTD

Re: SESSION LOST!
        254927 by: Yannick Warnier

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 ---
I am having a bit of a confusion printing the values of an array i have. When i 
print_r this array it contains the following:
 
Array ( [ValueA] => ValueA [ValueB] => valueB [TestValue] => TestValue [Errors] 
=> Array ( [0] => Array ( [ErrorId] => AD27JH [ErrorMsg] => OK ) ) )  
  I can get the values of ValueA, ValueB and TestValue but I am a bit confused 
at getting the values of ErrorId and ErrorMsg.
   
  e.g. echo $arrayName['ValueA'];  // will display the value contained there
  
am thinking echo $arrayName['Errors']['ErrorId']; // should display the value 
but it does not
  Anyone wants to shed more light ?
  
Cheers


 
---------------------------------
8:00? 8:25? 8:40?  Find a flick in no time
 with theYahoo! Search movie showtime shortcut.

--- End Message ---
--- Begin Message ---
On Monday 14 May 2007 18:41, Don Don wrote:

> am thinking echo $arrayName['Errors']['ErrorId']; // should display the
> value but it does not Anyone wants to shed more light ?

echo $arrayName['Errors'][0]['ErrorId']; // ??

-- 
Crayon

--- End Message ---
--- Begin Message ---
Don Don wrote:

I am having a bit of a confusion printing the values of an array i have. When i 
print_r this array it contains the following:
Array ( [ValueA] => ValueA [ValueB] => valueB [TestValue] => TestValue [Errors] => Array ( [0] => Array ( [ErrorId] => AD27JH [ErrorMsg] => OK ) ) ) I can get the values of ValueA, ValueB and TestValue but I am a bit confused at getting the values of ErrorId and ErrorMsg. e.g. echo $arrayName['ValueA']; // will display the value contained there am thinking echo $arrayName['Errors']['ErrorId']; // should display the value but it does not
  Anyone wants to shed more light ?

$arrayName['Errors'][0]['ErrorId']

Cheers,

Rich
--
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

--- End Message ---
--- Begin Message ---
oops ! [0] 
   
  cheers

Richard Davey <[EMAIL PROTECTED]> wrote:
  Don Don wrote:

> I am having a bit of a confusion printing the values of an array i have. When 
> i print_r this array it contains the following:
> 
> Array ( [ValueA] => ValueA [ValueB] => valueB [TestValue] => TestValue 
> [Errors] => Array ( [0] => Array ( [ErrorId] => AD27JH [ErrorMsg] => OK ) ) ) 
> I can get the values of ValueA, ValueB and TestValue but I am a bit confused 
> at getting the values of ErrorId and ErrorMsg.
> 
> e.g. echo $arrayName['ValueA']; // will display the value contained there
> 
> am thinking echo $arrayName['Errors']['ErrorId']; // should display the value 
> but it does not
> Anyone wants to shed more light ?

$arrayName['Errors'][0]['ErrorId']

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

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



       
---------------------------------
Luggage? GPS? Comic books? 
Check out fitting  gifts for grads at Yahoo! Search.

--- End Message ---
--- Begin Message ---
Don Don wrote:
> I am having a bit of a confusion printing the values of an
> array i have. When i print_r this array it contains the following:
> 
> Array ( [ValueA] => ValueA [ValueB] => valueB [TestValue] =>
> TestValue [Errors] => Array ( [0] => Array ( [ErrorId] =>
> AD27JH [ErrorMsg] => OK ) ) )
>   I can get the values of ValueA, ValueB and TestValue but I
> am a bit confused at getting the values of ErrorId and ErrorMsg.
> 
>   e.g. echo $arrayName['ValueA'];  // will display the value
> contained there 
> 
> am thinking echo $arrayName['Errors']['ErrorId']; // should
> display the value but it does not
>   Anyone wants to shed more light ?
> 
> Cheers

echo $arrayName['Errors'][0]['ErrorId'];

-B

--- End Message ---
--- Begin Message ---
Don Don wrote:
I am having a bit of a confusion printing the values of an array i have. When i 
print_r this array it contains the following:
Array ( [ValueA] => ValueA [ValueB] => valueB [TestValue] => TestValue [Errors] => Array ( [0] => Array ( [ErrorId] => AD27JH [ErrorMsg] => OK ) ) ) I can get the values of ValueA, ValueB and TestValue but I am a bit confused at getting the values of ErrorId and ErrorMsg. e.g. echo $arrayName['ValueA']; // will display the value contained there am thinking echo $arrayName['Errors']['ErrorId']; // should display the value but it does not
  Anyone wants to shed more light ?
Cheers


---------------------------------
8:00? 8:25? 8:40?  Find a flick in no time
 with theYahoo! Search movie showtime shortcut.
suggestion for next time. echo a <pre> or <plaintext> tag out before you echo your array next time and you will then see the nesting of the arrays

Doing that would have made the answer to this question very obvious

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Unknown

--- End Message ---
--- Begin Message ---
Jim Lucas wrote:--

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Unknown


Malvolio,12th Night, III.iv

--

_____________________
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/

--- End Message ---
--- Begin Message ---
Jim Lucas wrote:

suggestion for next time. echo a <pre> or <plaintext> tag out before you echo your array next time and you will then see the nesting of the arrays

Doing that would have made the answer to this question very obvious

You could also benefit from installing this very handy little bit of code into your PHP project:

http://krumo.sourceforge.net/

Cheers,

Rich
--
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

--- End Message ---
--- Begin Message ---
On Monday 14 May 2007 07:30, Daniel Brown wrote:

Please don't top post.

>     The biggest thing to remember is that a license is like a key....
> it's meant to keep an honest man honest, but won't stop someone who is
> intent on taking what they want for a profit.

Sure, but if you don't make your intentions clear from the start then 
there's no use complaining afterwards. Not quite an accurate analogy but 
here goes:

"If you leave valuables around your house and leave the doors and windows 
unlocked you're not going to get much sympathy from the police (or the 
insurance company for that matter) when you get burgled."

So, if you don't use a suitable license then you don't have a stick to 
beat someone with should it ever come to it.

-- 
Crayon

--- End Message ---
--- Begin Message ---
Mohamed CHAARI wrote:
> Hi all,
> 
> I have to execute an external command, with an argument
> (filename or directory name) given by user input (via a
> form), ie something like this:
> 
> exec('ls $_POST[...]')
> 
> what do you think about using escapeshellarg() function in
> this case ?
> can I rely on it to have a secure solution ? or is there a risk ? ...
> 
> 
> thank you.

In addition to using escapeshellarg(), I would first determine if the input
file or directory exists before executing the command.  This adds another
layer of protection.

<?php

// Example code

if(file_exists($_POST['file_or_dir_name'])) {
        $command = "ls ".escapeshellarg($_POST['file_or_dir_name']);    
        exec($command);
} else {
        echo "File/Directory does not exist!!";
}
?>

-B

--- End Message ---
--- Begin Message ---
Can anyone point me to some good online reference/examples of
reading/writing XML documents?


Thanks,

Anthony


--- End Message ---
--- Begin Message ---
> 
> Can anyone point me to some good online reference/examples of
> reading/writing XML documents?
> 

With regards to PHP?  Sure!  http://us2.php.net/xml

JM

--- End Message ---
--- Begin Message ---
http://www.php-code-search.com/?q=xml

Check out the Articles section

berber 

-----Original Message-----
From: Anthony J. Maske [mailto:[EMAIL PROTECTED] 
Sent: Monday, May 14, 2007 9:44 PM
To: PHP General
Subject: [PHP] Reading & Writing XML Documents...

Can anyone point me to some good online reference/examples of
reading/writing XML documents?


Thanks,

Anthony

--- End Message ---
--- Begin Message ---
Le jeudi 10 mai 2007 à 15:24 +0200, Oliver Block a écrit :
> Am Donnerstag, 10. Mai 2007 08:59 schrieb Sascha Braun:
> > but after a little
> > time, the session is just lost.
> 
> That doesn't say anything to me. Could you be more verbose on what you mean 
> by 
> "the sessin is lost"?

:-)

I get that too and it's the best description I could give in one
sentence. Basically, the session array $_SESSION is emptied. Without
notice, warning or error. Just emptied.

I tried to track it down with xdebug as well but it's really just
loosing it.

I will try to work on this problem this week, and basically looking at
the last hundreds of posts about sessions in this list, I would narrow
it down to the following possible problems and solutions:

1) Unsynched:
It is possible that client and server do not share the same notion of
time, which is stored in the session cookies, so the session would be
expired sooner than expected. A way to test if this is the problem is to
set the cookie lifetime to one year or more, and see if it improves
anything. However, if this was the problem, timeouts would tend to
happen after a definite period of time, not after a random period like I
have and like Sascha seems to have as well

2) Mutex 1:
The problem might be due to concurrent (or almost) uses of the session,
either with AJAX code or with frames, which might mean that the sessions
are not complete when accessed, or access is prevented by a blocking
write operation on the session file. This should only happen in the
context of concurrent requests, and the only possible improvement might
be to use session_write_close() as soon as a session use is finished, or
to use mutex-aware session handler functions.
I wonder if, in this case, the session should really be lost and
emptied... maybe a write still allows a read to work...

3) Mutex 2:
When using alternative session handlers, these session handlers might
not be mutex-aware, so a concurrent access prevents data from being
written before it is read. Make sure your session handling code is
mutex-aware (apparently there is some code documented in the user
comments of the PHP online doc).

I hope this helps. I'll try to come back and report if any of these
solutions has worked for me.

Yannick

--- End Message ---

Reply via email to