Re: [PHP] json_encode confusion

2011-11-11 Thread Richard Quadling
On 10 November 2011 14:45, Bastien Koert  wrote:
> Morning all,
>
> I've been having some fun with converting a text data file import into
> a json object for storage.
>
> I have a text file that is pipe delimited coming in via an upload. The
> first row is the headers and the second row is the data.
>
> Using this code:
>
> $data = file("inline_Nov_8_2011.txt");
>
> if(count($data)==2){
>
>        $keys   = explode("|", $data[0]);
>        $fields = explode("|", $data[1]);
>
>        $combine = array_combine($keys, $fields);
>
>        $json = json_encode($combine);
> }
>
> After the combine, I get an array that looks like this
>
> Array
> (
>    ['Legal Last Name '] => Andros
>    ['Legal Middle Initial '] =>
>    ['Legal First Name '] => Marisa
>    ['Maiden/Other Name '] =>
>    ['Social Insurance No. '] => 123456789
>    ['Date of Birth '] => 2/1/1988
>    ['Gender '] => Female
> )
>
> But the json encoded value looks like this (there are way more
> elements but this should be enough to represent what I need to do).
>
> {null:"Andros",null:"",null:"Marisa",null:"",null:"123456789",null:"2\/1\/1988",null:"Female"}
>
> I have been googling for info about allowed values for the json keys,
> but can't seem to find a clear doc on what is allowed and what isn't.
> I have tried unquoted keys, replaced the spaced with underscores but
> nothing I do seems to help.
>
> When I echo out the json encoded data, the keys are all nulls.
>
> Can someone point me in the correct direction? It may be that I need
> to manually create the key names as an array first, which I was hoping
> to avoid since the file format coming from the client is still in some
> flux.

 'Andros',
   'Legal Middle Initial ' => '',
   'Legal First Name ' => 'Marisa',
   'Maiden/Other Name ' => '',
   'Social Insurance No. ' => 123456789,
   'Date of Birth ' => '2/1/1988',
   'Gender ' => 'Female'
);

echo json_encode($data, JSON_FORCE_OBJECT);
?>

outputs ...

{"Legal Last Name ":"Andros","Legal Middle Initial ":"","Legal First
Name ":"Marisa","Maiden\/Other Name ":"","Social Insurance No.
":123456789,"Date of Birth ":"2\/1\/1988","Gender ":"Female"}


-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc : Fantasy Shopper
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea :
fan.sh/6/370

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



Re: [PHP] Headers already sent

2011-11-11 Thread Marc Guay
> Thanks. That was the problem. I spent a day trying to debug this.

Smash head against wall first, ask questions later.  That's my
methodology as well.  :)

Marc

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



[PHP] Frivolous Friday Fun!

2011-11-11 Thread Jason Pruim
The wife of a programmer to his husband:
Quote:
Darling, 
I'm starting to get a little worried about your work; you work too much... 
you spend more time with your CPU than with me... You program too much...
Her husband answers, to calm her:
Code:
!Honey; 
if(you.IsThinking(this)) !Worry;
CLove* myself = new CLove;   //I love you darling
while(world.DoExist()) 
{
 myself->m_bLoveForYou++;
 if(!myself->IsTrue())
 {
  delete myself;
  _exit(-1);
 }
}


And on a serious note... To any Past, Present, Or Future service man (Or woman) 
Thank you for your sacrifice in defending our ability to send out these 
Frivolous Friday emails! :)


Jason Pruim
li...@pruimphotography.com





Re: [PHP] Frivolous Friday Fun!

2011-11-11 Thread Marc Guay
>     if(!myself->IsTrue())
>     {
>          delete myself;
>          _exit(-1);
>     }

I like this part...


> And on a serious note... To any Past, Present, Or Future service man (Or 
> woman) Thank you for your sacrifice in defending our ability to send out 
> these Frivolous Friday emails! :)

... but not so much this part.  *I* can send Frivolous Friday emails
in spite of war, not because of it; please watch your "our"s.

Marc

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



Re: [PHP] Frivolous Friday Fun!

2011-11-11 Thread Daniel Brown
On Fri, Nov 11, 2011 at 13:15, Marc Guay  wrote:
>
> ... but not so much this part.  *I* can send Frivolous Friday emails
> in spite of war, not because of it; please watch your "our"s.

"Our" does not automatically become all-inclusive, but rather
suggests that the individual is part of a larger group.  Please watch
your presumptions of being force-included into said group, as the
statement is valid regardless of anyone's personal opinion.  ;-P

-- 

Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] Frivolous Friday Fun!

2011-11-11 Thread Marc Guay
>    "Our" does not automatically become all-inclusive, but rather
> suggests that the individual is part of a larger group.  Please watch
> your presumptions of being force-included into said group, as the
> statement is valid regardless of anyone's personal opinion.  ;-P

Crap, you're right.

My apologies to myself for including myself in a group I didn't want
to be a part of.

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



Re: [PHP] Frivolous Friday Fun!

2011-11-11 Thread muad shibani
I love it

On Fri, Nov 11, 2011 at 9:22 PM, Marc Guay  wrote:

> >"Our" does not automatically become all-inclusive, but rather
> > suggests that the individual is part of a larger group.  Please watch
> > your presumptions of being force-included into said group, as the
> > statement is valid regardless of anyone's personal opinion.  ;-P
>
> Crap, you're right.
>
> My apologies to myself for including myself in a group I didn't want
> to be a part of.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
*___*
*
*
السجل .. كل الأخبار من كل مكان

www.alsjl.com

صفحة السجل على فيسبوك
http://www.facebook.com/alsjl

*Muad Shibani*
*
*
Aden Yemen
Mobile: 00967 733045678

www.muadshibani.com


[PHP] Up to date book on PHP security?

2011-11-11 Thread Keith Purtell
As a PHP newbie, I was advised to get a book by Chris Shiflett titled 
"Essential PHP Security." I looked at Amazon.com but the book appears to 
be more than five years old. Should I get something more up to date?


- Keith


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



Re: [PHP] Up to date book on PHP security?

2011-11-11 Thread Alain Williams
On Fri, Nov 11, 2011 at 05:01:19PM -0600, Keith Purtell wrote:
> As a PHP newbie, I was advised to get a book by Chris Shiflett titled 
> "Essential PHP Security." I looked at Amazon.com but the book appears to 
> be more than five years old. Should I get something more up to date?

It is a good book -- easy to read, 1/2 day, and gives you a big picture.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include 

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



Re: [PHP] Frivolous Friday Fun!

2011-11-11 Thread George Langley

On 2011-11-11, at 11:08 AM, Jason Pruim wrote:
> 
> 
> And on a serious note... To any Past, Present, Or Future service man (Or 
> woman) Thank you for your sacrifice in defending our ability to send out 
> these Frivolous Friday emails! :)

You're welcome!

CPO2 George Langley
HMCS TECUMSEH Naval Reserve
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Pipe To A Program

2011-11-11 Thread Ron Piggott

I am looking at CPanel’s “E-Mail filtering” option “Pipe To A Program”
http://docs.cpanel.net/twiki/bin/view/AllDocumentation/CpanelDocs/FilterOptions

The goal I am working towards is saving the contents of an incoming e-mail 
address into a mySQL table.  I am thinking of trying to program a customer 
contact center application.

Does anyone know what variable the e-mail message is assigned within the 
context of “Pipe To A Program”?  Is there a way to find out?  I can’t figure 
this out.  

What I have tried so far is below:

===
#!/usr/local/bin/php -q
 $val) {
 $$key = $val;
 
$email_body .= "KEY: " . $key . "\r\n";
$email_body .= "VAL: " . $val . "\r\n";
$email_body .= "\r\n";

}

mail( user@domain , "Test Pipe To Program" , $email_body );
===

The mail command works, but the e-mail message body is empty.   I am at a loss 
of how to proceed.

Ron