Re: [PHP] Saving form data into session before leaving a page

2010-04-14 Thread Ashley Sheridan
On Wed, 2010-04-14 at 06:49 +0100, Lester Caine wrote:

> Nathan Rixham wrote:
> > Peter Lind wrote:
> >> On 13 April 2010 17:27, Paul M Foster  wrote:
> >>> On Tue, Apr 13, 2010 at 03:20:23PM +0200, Merlin Morgenstern wrote:
> >>>
>  Hello everybody,
> 
>  I have form where users enter data to be saved in a db.
> 
>  How can I make php save the form data into a session before the user
>  leaves the page without pressing the submit button? Some members leave
>  the page and return afterwards wondering where their already entered
>  data is.
> >>> I hate to be a contrarian (not really), but there is a paradigm for
> >>> using web forms. If you want the internet to save your data, you have to
> >>> press the little button. If you don't, then it won't be saved. Not hard
> >>> to figure out, not hard to do. If you have to go do something else while
> >>> you're in the middle of a form, open a new tab/window and do it. When
> >>> you come back to your original form, the data will still be there (but
> >>> again, not *saved* until you hit the little button).
> >>>
> >>> Sorry, I just get cranky with people who won't follow the rules.
> >>
> >> There are rules and then there's stupidity based on tradition. The
> >> fact that websites previously threw away whatever work you had done
> >> because you automatically got logged out of your session after half an
> >> hour of typing does not mean you should call this a rule that should
> >> be adhere to. Google figured it out and did so well: backup
> >> automatically and let the user discard manually - not the other way
> >> round that leads to lost work.
> >>
> >> Apart from that, I note that the OP has seemingly managed to solve the
> >> problem and all these emails are rather pointless.
> >
> > Concur, and this is nothing to do with the web; http only constrains
> > that the data should be POSTed or PUT; not /when/ a save action is
> > triggered.
> >
> > Functionality is in the realm of the application, and if the client
> > application (in this case the web page) determines that information
> > should be iteratively saved, then that's what it should do.
> >
> > see google docs, gmail etc for real world examples.
> 
> And a few BANK sites could do with considering waring people that they will 
> time 
> out before you have time to actually write in their message box for on-line 
> emails which you have to use since they will not accept off-line ones. I had 
> a 
> complex message FROM them to answer - and save just told me the seesion had 
> timed out! Bank solution - I should have copied their message to a word 
> processor, and then copied the answer back later ... perhaps they should add 
> that with a warning when trying to use their email page ;)
> 
> -- 
> Lester Caine - G8HFL
> -
> Contact - http://lsces.co.uk/wiki/?page=contact
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk//
> Firebird - http://www.firebirdsql.org/index.php
> 


Banks are notorious for not knowing about technology. My bank has a
constant popup for Windows software that I 'must install' and has even
asked me before to send my bank details over unencrypted email (my
actual bank and not a phishing scam, as it was in reply to a question
about that darned popup!)

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Array differences

2010-04-14 Thread Ashley Sheridan
On Tue, 2010-04-13 at 23:01 -0600, Ashley M. Kirchner wrote:

> I have the following scenario:
> 
>  
> 
>  $array1 = array("12", "34", "56", "78", "90");
> 
>  $array2 = array("12", "23", "56", "78", "89");
> 
>  
> 
>  $result = array_diff($array1, $array2);
> 
>  
> 
>  print_r($result);
> 
>  
> 
> 
> 
> This returns:
> 
>  
> 
>  Array
> 
>  (
> 
>  [1] => 34
> 
>  [4] => 90
> 
>  )
> 
>  
> 
> 
> 
> However what I really want is a two-way comparison.  I want elements that
> don't exist in either to be returned:
> 
>  
> 
> 34 and 90 because they don't exist in $array2, AND 23 and 89 because they
> don't exist in $array1.  So, is that a two step process of first doing an
> array_diff($array1, $array2) then reverse it by doing array_diff($array2,
> $array1) and merge/unique the results?  Any caveats with that?
> 
>  
> 
>  $array1 = array("12", "34", "56", "78", "90");
> 
>  $array2 = array("12", "23", "56", "78", "89");
> 
>  
> 
>  $diff1 = array_diff($array1, $array2);
> 
>  $diff2 = array_diff($array2, $array1);
> 
>  
> 
>  $result = array_unique(array_merge($diff1, $diff2));
> 
>  
> 
>  print_r($result);
> 
>  
> 
> 
> 
> -- A
> 


I don't see any problems with doing it that way. This will only work as
you intended if both arrays have the same number of elements I believe,
otherwise you might end up with a situation where your final array has
duplicates of the same number:

$array1 = $array(1, 2, 3, 4, 5, 6);
$array2 = $aray(1, 3, 2, 5);

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] Re: would there be an interest in having htmlMicroscope include dygraphs?

2010-04-14 Thread Nathan Rixham
Rene Veerman wrote:
> 
> I would like to include http://www.danvk.org/dygraphs/ into htmlMicroscope.
> Would you think it usefull?

+1

> Yes, i am a bit worried about being seen as the weird psycho on this
> forum. Psychotic i'm not, just sleep-deprived a bit

1: if you you didn't bring personal life in to your mails then you
wouldn't have to worry, the quicker you stop mentioning it the sooner it
will be forgotten

2: most developers, perhaps take the approach of the rest of us and
simply get a bit ratty, make stupid typo's and ask questions about
things you already know (but forgot, because you are tired).

> My reasons for posting "[OFF-TOPIC] telepathy and psychiatery" to this
> list were simple; i was trying to alleviate the fears of other
> telepaths like me, to prevent _them_ from having to go through the
> hell of psychiateric closed wards...

Rene, Telepathic or not, it is of no concern to any body on the list,
just as we do not take it upon ourselves to inform you of the various
physical and mental problems affecting many of us on a daily basis -
some people on this list have *very* serious health problems, and we're
just lucky they are still with us.

In short, this list is a place where we discuss PHP, which is our tool
for work, our hobby, another thing to help drown out the difficulties of
life - embrace the code and let it see you through the hard times, keep
personal life; personal.

If you feel like replying Rene, quickly skip back to the top, notice the
+1 and get on making good use of your time with a good challenge and
some learning to boot.

We're all happy to help you with any (PHP or Code) issues you may have
along the way.

Regards!

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



Re: [PHP] Array differences

2010-04-14 Thread Nathan Rixham
Ashley Sheridan wrote:
> On Tue, 2010-04-13 at 23:01 -0600, Ashley M. Kirchner wrote:
>>
>> However what I really want is a two-way comparison.  I want elements that
>> don't exist in either to be returned:
>>
> 
> 
> I don't see any problems with doing it that way. 

By some freak chance I made an array diff class about 2 weeks ago which
covers what you need. attached :)

usage:

$diff = new ArrayDiff( $old , $new );
$diff->l; // deleted items
$diff->r; // inserted items
$diff->u; // unchanged items

The script is optimised for huge arrays, thus it's slower for small
arrays than the usual array_diff but with large arrays it's quicker.

Regards

Nathan

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

Re: [PHP] Array differences

2010-04-14 Thread Rene Veerman
On Wed, Apr 14, 2010 at 12:03 PM, Nathan Rixham  wrote:
> Ashley Sheridan wrote:
>> On Tue, 2010-04-13 at 23:01 -0600, Ashley M. Kirchner wrote:
>>>
>>> However what I really want is a two-way comparison.  I want elements that
>>> don't exist in either to be returned:
>>>
>>
>>
>> I don't see any problems with doing it that way.
>
> By some freak chance I made an array diff class about 2 weeks ago which
> covers what you need. attached :)
>
> usage:
>
> $diff = new ArrayDiff( $old , $new );
> $diff->l; // deleted items
> $diff->r; // inserted items
> $diff->u; // unchanged items
>
> The script is optimised for huge arrays, thus it's slower for small
> arrays than the usual array_diff but with large arrays it's quicker.
>
> Regards
>
> Nathan
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

nice one :) i'll put it in a work-preperation folder for
htmlMicroscope then, one of these days :)

-- 
-
Greetings from Rene7705,

I have made some free open source webcomponents designed
and written by me available through:
http://code.google.com/u/rene7705/ , or
http://mediabeez.ws (latest dev versions, currently offline)

Personal info about me is available through http://www.facebook.com/rene7705
-

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



Re: [PHP] Array differences

2010-04-14 Thread Ashley M. Kirchner

On 4/14/2010 2:39 AM, Ashley Sheridan wrote:

On Tue, 2010-04-13 at 23:01 -0600, Ashley M. Kirchner wrote:

  $array1 = array("12", "34", "56", "78", "90");
  $array2 = array("12", "23", "56", "78", "89");

  $diff1 = array_diff($array1, $array2);
  $diff2 = array_diff($array2, $array1);

  $result = array_unique(array_merge($diff1, $diff2));

  print_r($result);
 


I don't see any problems with doing it that way. This will only work 
as you intended if both arrays have the same number of elements I 
believe, otherwise you might end up with a situation where your final 
array has duplicates of the same number:


$array1 = $array(1, 2, 3, 4, 5, 6);
$array2 = $aray(1, 3, 2, 5);


Wouldn't array_unique() take care of that though?  Your example 
above returns 4 and 6, which would be correct.


A

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



Re: [PHP] Array differences

2010-04-14 Thread Ryan Sun
Maybe this one works?
array_diff(array_unique($array1 + $array2), array_intersect($array1, $array2))

On Wed, Apr 14, 2010 at 4:39 AM, Ashley Sheridan
 wrote:
> On Tue, 2010-04-13 at 23:01 -0600, Ashley M. Kirchner wrote:
>
>> I have the following scenario:
>>
>>
>>
>>      $array1 = array("12", "34", "56", "78", "90");
>>
>>      $array2 = array("12", "23", "56", "78", "89");
>>
>>
>>
>>      $result = array_diff($array1, $array2);
>>
>>
>>
>>      print_r($result);
>>
>>
>>
>>
>>
>> This returns:
>>
>>
>>
>>      Array
>>
>>      (
>>
>>          [1] => 34
>>
>>          [4] => 90
>>
>>      )
>>
>>
>>
>>
>>
>> However what I really want is a two-way comparison.  I want elements that
>> don't exist in either to be returned:
>>
>>
>>
>> 34 and 90 because they don't exist in $array2, AND 23 and 89 because they
>> don't exist in $array1.  So, is that a two step process of first doing an
>> array_diff($array1, $array2) then reverse it by doing array_diff($array2,
>> $array1) and merge/unique the results?  Any caveats with that?
>>
>>
>>
>>      $array1 = array("12", "34", "56", "78", "90");
>>
>>      $array2 = array("12", "23", "56", "78", "89");
>>
>>
>>
>>      $diff1 = array_diff($array1, $array2);
>>
>>      $diff2 = array_diff($array2, $array1);
>>
>>
>>
>>      $result = array_unique(array_merge($diff1, $diff2));
>>
>>
>>
>>      print_r($result);
>>
>>
>>
>>
>>
>> -- A
>>
>
>
> I don't see any problems with doing it that way. This will only work as
> you intended if both arrays have the same number of elements I believe,
> otherwise you might end up with a situation where your final array has
> duplicates of the same number:
>
> $array1 = $array(1, 2, 3, 4, 5, 6);
> $array2 = $aray(1, 3, 2, 5);
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

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



RE: [PHP] Array differences

2010-04-14 Thread Ashley M. Kirchner
No because that only does a one-way comparison.  It only tells me what's
missing from $array2.  I need it from both arrays.  That's why I'm comparing
1 versus 2, then 2 versus 1, and then doing a merge/unique on the result.

$array1 = array(1, 2, 3, 4, 5, 6);
$array2 = array(1, 3, 2, 8, 9);
$result = array_diff(array_unique($array1 + $array2),
array_intersect($array1, $array2));

=> (4, 5, 6)


Versus:

$array1 = array(1, 2, 3, 4, 5, 6);
$array2 = array(1, 3, 2, 8, 9);
$diff1  = array_diff($array1, $array2);
$diff2  = array_diff($array2, $array1);
$result = array_unique(array_merge($diff1, $diff2));

=> (4, 5, 6, 8, 9)

This second $result is what I want.  So far I haven't noticed any problems
doing it this way ... yet.  I'm sure someone will tell me otherwise.

Ash

> -Original Message-
> From: Ryan Sun [mailto:ryansu...@gmail.com]
> Sent: Wednesday, April 14, 2010 8:45 AM
> To: a...@ashleysheridan.co.uk
> Cc: Ashley M. Kirchner; php-general@lists.php.net
> Subject: Re: [PHP] Array differences
> 
> Maybe this one works?
> array_diff(array_unique($array1 + $array2), array_intersect($array1,
> $array2))
> 
> On Wed, Apr 14, 2010 at 4:39 AM, Ashley Sheridan
>  wrote:
> > On Tue, 2010-04-13 at 23:01 -0600, Ashley M. Kirchner wrote:
> >
> >> I have the following scenario:
> >>
> >>
> >>
> >>      $array1 = array("12", "34", "56", "78", "90");
> >>
> >>      $array2 = array("12", "23", "56", "78", "89");
> >>
> >>
> >>
> >>      $result = array_diff($array1, $array2);
> >>
> >>
> >>
> >>      print_r($result);
> >>
> >>
> >>
> >>
> >>
> >> This returns:
> >>
> >>
> >>
> >>      Array
> >>
> >>      (
> >>
> >>          [1] => 34
> >>
> >>          [4] => 90
> >>
> >>      )
> >>
> >>
> >>
> >>
> >>
> >> However what I really want is a two-way comparison.  I want elements
> that
> >> don't exist in either to be returned:
> >>
> >>
> >>
> >> 34 and 90 because they don't exist in $array2, AND 23 and 89 because
> they
> >> don't exist in $array1.  So, is that a two step process of first
> doing an
> >> array_diff($array1, $array2) then reverse it by doing
> array_diff($array2,
> >> $array1) and merge/unique the results?  Any caveats with that?
> >>
> >>
> >>
> >>      $array1 = array("12", "34", "56", "78", "90");
> >>
> >>      $array2 = array("12", "23", "56", "78", "89");
> >>
> >>
> >>
> >>      $diff1 = array_diff($array1, $array2);
> >>
> >>      $diff2 = array_diff($array2, $array1);
> >>
> >>
> >>
> >>      $result = array_unique(array_merge($diff1, $diff2));
> >>
> >>
> >>
> >>      print_r($result);
> >>
> >>
> >>
> >>
> >>
> >> -- A
> >>
> >
> >
> > I don't see any problems with doing it that way. This will only work
> as
> > you intended if both arrays have the same number of elements I
> believe,
> > otherwise you might end up with a situation where your final array
> has
> > duplicates of the same number:
> >
> > $array1 = $array(1, 2, 3, 4, 5, 6);
> > $array2 = $aray(1, 3, 2, 5);
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >


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



[PHP] How to achieve mixed authentication/anonymous access

2010-04-14 Thread Dirk Thomas / 4wd media

Hi,

i have a problem with Authentification.
I currently doubt that it is possible at all.
Perhaps someone can enlighten me how to achive the goal or confirm that it is 
not reachable.

The scenario is to achieve a mixed authentication/anonymous access similar as 
described for Subversion (see 
http://svnbook.red-bean.com/nightly/de/svn-book.html#svn.serverconfig.httpd.authz.perdir.ex-3).

Therefore the ".htaccess" looks something like that:
  Order allow,deny
  Allow from all
  AuthType Basic
  AuthName "Realm"
  AuthUserFile "/some/path/.htusers"
  require valid-user
  Satisfy any

Additionally a PHP script is inside the same folder.
When you now browse to the URL of the PHP script, you can access it without any 
credentials requested.

At some point the PHP script "decides" that authentification is required (e.g. when 
passing a param like "?access-secret=1").
Therefore it sends the following two headers:
  WWW-Authenticate: Basic realm="Realm"
  HTTP/1.x 401 Unauthorized

Then you are asked to insert your username/password for the basic auth.

But now comes the problem:
How can the PHP script determine if you have provided valid credentials?
The server variables PHP_AUTH_USER and PHP_AUTH_PW are populated independent of 
the result of the authentification defined in Apache.

I do explicitly not want to check the credentials in PHP - think of the many 
different auth-methods which could be configured with Apache.
Nor can the anonymous and authenticated parts be split in separate folders.

Is this goal even possible or is the only way to not allow anonymous access (but for 
replacement a dummy user like "guest" with no password) or implement the auth 
in PHP?

Any feedback is highly appreciated.

Thank you
Dirk

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



Re: [PHP] Basic switch statement

2010-04-14 Thread tedd

At 10:04 PM +0100 4/13/10, Nathan Rixham wrote:

Robert Cummings wrote:
 > Nathan Rixham wrote:

 > Fail on that last one. -1 is not equivalent to FALSE :B

well that's one job I'm not getting :p

cheers for the picking that one up Rob


And that's the reason why I hate test like that!

The short tricky logic questions that interviewer's use to be clever 
are just nonsense.


I'll take someone who can solve a problem over one who can argue 
true/false logic tables every time. Not meaning that people who come 
natural to that sort of logic solving ability do not make good 
programmers (because they can -- like Rob), but rather people who 
fail those types of logic questions do NOT also fail to be good 
programmers (like me). It's similar to the Tortoise and Hare thing -- 
it really doesn't make any difference who gets there first for both 
can run the distance.


I don't think those types of logic puzzles do much to measure 
anything other than people's ability to solve logic puzzles. IMO, 
it's interviewers "leap of faith" to think logic puzzles are a good 
indicator of programming prowess. To many of us, programming is just 
doing over until it works.


Cheers,

tedd

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

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



Re: [PHP] Array differences

2010-04-14 Thread lala

Ashley M. Kirchner wrote:


$array1 = array(1, 2, 3, 4, 5, 6);
$array2 = array(1, 3, 2, 8, 9);
$diff1  = array_diff($array1, $array2);
$diff2  = array_diff($array2, $array1);
$result = array_unique(array_merge($diff1, $diff2));

=> (4, 5, 6, 8, 9)


Hi Ash,

Isn't the array_unique() unnecessary?

Mike

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



RE: [PHP] Array differences

2010-04-14 Thread Ashley M. Kirchner
> -Original Message-
> From: lala [mailto:l...@mail.theorb.net]
> Sent: Wednesday, April 14, 2010 10:15 AM
> To: Ashley M. Kirchner
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Array differences
> 
> Ashley M. Kirchner wrote:
> >
> > $array1 = array(1, 2, 3, 4, 5, 6);
> > $array2 = array(1, 3, 2, 8, 9);
> > $diff1  = array_diff($array1, $array2);
> > $diff2  = array_diff($array2, $array1);
> > $result = array_unique(array_merge($diff1, $diff2));
> >
> > => (4, 5, 6, 8, 9)
> 
> Hi Ash,
> 
> Isn't the array_unique() unnecessary?
> 
> Mike


Thinking about it, it should be unnecessary, but at the same time I want to 
absolutely sure that I get unique values out of the two diffs.

Ash


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



Re: [PHP] Basic switch statement

2010-04-14 Thread tedd

At 5:06 PM -0400 4/13/10, Robert Cummings wrote:

Nathan Rixham wrote:


well that's one job I'm not getting :p


Well you DID get 66.7%. I've met "coders" that would stare at the 
answer and still not understand :D


Cheers,
Rob.


Well.. count me among those staring. I just don't get those type of 
things until I see them actually work.


My "logic" works the other way -- when presented with a logic 
problem, I come up with a solution that works the way I think and I 
always to solve the problem presented. Perhaps my solution isn't as 
clever nor as cryptic as others, but it's always easier to read and 
understand.


Cheers,

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

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



Re: [PHP] Basic switch statement

2010-04-14 Thread Robert Cummings

tedd wrote:

At 5:06 PM -0400 4/13/10, Robert Cummings wrote:

Nathan Rixham wrote:

well that's one job I'm not getting :p
Well you DID get 66.7%. I've met "coders" that would stare at the 
answer and still not understand :D


Cheers,
Rob.


Well.. count me among those staring. I just don't get those type of 
things until I see them actually work.


My "logic" works the other way -- when presented with a logic 
problem, I come up with a solution that works the way I think and I 
always to solve the problem presented. Perhaps my solution isn't as 
clever nor as cryptic as others, but it's always easier to read and 
understand.


Maybe you haven't debugged enough "other people" code in your time as a 
developer... there's a  certain knack to weeding out logic failures :)


It also helps to use proper indentation and bracing format as 
illustrated by all my code examples so that you can more easily see 
where problems lie >:D


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

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



Re: [PHP] Basic switch statement

2010-04-14 Thread tedd

At 12:32 PM -0400 4/14/10, Robert Cummings wrote:

tedd wrote:
My "logic" works the other way -- when presented with a logic 
problem, I come up with a solution that works the way I think and I 
always to solve the problem presented. Perhaps my solution isn't as 
clever nor as cryptic as others, but it's always easier to read and 
understand.


Maybe you haven't debugged enough "other people" code in your time 
as a developer... there's a  certain knack to weeding out logic 
failures :)


That could very well be. I don't usually debug other people's code 
and seldom have clients want me to do so. I usually have clients who 
present a problem and then I solve it -- thus, all original code.


Several yeas ago, I had one client who had considerable prior work 
done and I found myself rewriting everything at a cost of many weeks 
of my non-billable time. I won't be doing that again.


It also helps to use proper indentation and bracing format as 
illustrated by all my code examples so that you can more easily see 
where problems lie >:D


Cheers,
Rob.


Ain't that the truth!

We are almost identical in our formatting.

I've found that when I run into someone who has similar ideas as I 
have, they are usually very intelligent.  :-)


Cheers,

tedd

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

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



RE: [PHP] Array differences

2010-04-14 Thread tedd

At 9:37 AM -0600 4/14/10, Ashley M. Kirchner wrote:

No because that only does a one-way comparison.  It only tells me what's
missing from $array2.  I need it from both arrays.  That's why I'm comparing
1 versus 2, then 2 versus 1, and then doing a merge/unique on the result.

-snip-
$array1 = array(1, 2, 3, 4, 5, 6);
$array2 = array(1, 3, 2, 8, 9);
$diff1  = array_diff($array1, $array2);
$diff2  = array_diff($array2, $array1);
$result = array_unique(array_merge($diff1, $diff2));

=> (4, 5, 6, 8, 9)

This second $result is what I want.  So far I haven't noticed any problems
doing it this way ... yet.  I'm sure someone will tell me otherwise.

Ash


Ash:

Looks good to me. But note the indexes of the result.

You might want to:

$array1 = array(1, 2, 3, 4, 5, 6, 7, 7, 7, 7);
$array2 = array(1, 2, 3, 8, 9);
$diff1  = array_diff($array1, $array2);
$diff2  = array_diff($array2, $array1);

$diff1 = array_unique($diff1);
$diff2 = array_unique($diff2);
$result = array_merge($diff1, $diff2);

Cheers,

tedd

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

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



RE: [PHP] PHP & MYSQL sorting

2010-04-14 Thread Ernie Kemp
Thanks for your thoughts. Ajax is the way to go...


Thanks,
.../Ernie

-Original Message-
From: tedd [mailto:tedd.sperl...@gmail.com] 
Sent: April-12-10 10:18 AM
To: Ernie Kemp; 'PHP General List'
Subject: Re: [PHP] PHP & MYSQL sorting

At 8:16 PM -0400 4/11/10, Ernie Kemp wrote:
>Simple idea I thought.
>
>I need a webpage that displays a drop down list of number with a 
>checkbox on the side that when checked will select the database 
>again only in descending order.
>Small database with maybe 100  records.
>
>The user can click the submit button when they have located the 
>correct number.
>
>The trick is to make the checkbox trigger a new Select statement.
>
>Thanks.

Ernie:





The javascript getData() will have to launch a php script to get the 
data again OR you can simply sort the data yourself using sort().

Here's another idea using jQuery:

http://webbytedd.com/jquery/sortable-table/

Cheers,

tedd


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

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


No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 9.0.801 / Virus Database: 271.1.1/2806 - Release Date: 04/12/10
02:32:00


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



Re: [PHP] Basic switch statement

2010-04-14 Thread Al



On 4/14/2010 12:28 PM, tedd wrote:

At 5:06 PM -0400 4/13/10, Robert Cummings wrote:

Nathan Rixham wrote:


well that's one job I'm not getting :p


Well you DID get 66.7%. I've met "coders" that would stare at the
answer and still not understand :D

Cheers,
Rob.


Well.. count me among those staring. I just don't get those type of
things until I see them actually work.

My "logic" works the other way -- when presented with a logic problem, I
come up with a solution that works the way I think and I always to solve
the problem presented. Perhaps my solution isn't as clever nor as
cryptic as others, but it's always easier to read and understand.

Cheers,

tedd


I'm with you Tedd. I'm forever cussing myself when I use a super clever trick to 
solve a logic problem and then later can't figure out how the damn thing worked 
even though I documented it.


Incidentally, about formatting scripts, one of the reasons I like phpEdit is 
that it has a terrific code beautifier.  You can set it for phpDoc or Pear 
rendering. And, it auto indents, etc. as you enter stuff.


Al...

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



Re: [PHP] Basic switch statement

2010-04-14 Thread Paul M Foster
On Wed, Apr 14, 2010 at 12:28:13PM -0400, tedd wrote:

> At 5:06 PM -0400 4/13/10, Robert Cummings wrote:
>> Nathan Rixham wrote:
>>>
>>> well that's one job I'm not getting :p
>>
>> Well you DID get 66.7%. I've met "coders" that would stare at the
>> answer and still not understand :D
>>
>> Cheers,
>> Rob.
>
> Well.. count me among those staring. I just don't get those type of
> things until I see them actually work.
>
> My "logic" works the other way -- when presented with a logic
> problem, I come up with a solution that works the way I think and I
> always to solve the problem presented. Perhaps my solution isn't as
> clever nor as cryptic as others, but it's always easier to read and
> understand.

+1

I've never had other coders looking over my shoulder, and I agonized for
years over whether my logical solutions were the "best" approach. Now I
just code and take pride in the fact that I can understand what I did
later (mostly).

Paul

-- 
Paul M. Foster

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



Re: [PHP] problems with feature '--with-pdo-oci' RPM (spec)

2010-04-14 Thread Kevin Kinsey

Raul da Silva {Sp4wn} wrote:

# rpm -qpl /usr/src/linux/RPMS/x86_64/php52-pdo-oci-5.2.12-2.fc11.x86_64.rpm
/etc/php.d/pdo_oci.ini
/usr/lib64/php/modules/pdo_oci.so

# rpm --test -ivh
/usr/src/redhat/RPMS/x86_64/php52-pdo-oci-5.2.12-2.fc11.x86_64.rpm
error: Failed dependencies:
libclntsh.so.10.1()(64bit) is needed by
php52-pdo-oci-5.2.12-2.fc11.x86_64

I checked this steps, its ok :

1)
# ls -l /usr/lib/oracle/10.2.0.4/client64/lib/libclntsh.so
lrwxrwxrwx 1 root root 17 2010-04-12 19:38 /usr/lib/oracle/
10.2.0.4/client64/lib/libclntsh.so -> libclntsh.so.10.1

2)
# ldconfig -p | grep libclntsh.so
libclntsh.so.10.1 (libc6,x86-64) => /usr/lib/oracle/
10.2.0.4/client64/lib/libclntsh.so.10.1
libclntsh.so (libc6,x86-64) => /usr/lib/oracle/
10.2.0.4/client64/lib/libclntsh.so

What is wrong ? , thanks for help


http://bugs.php.net/29301

??

Kevin Kinsey

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



Re: [PHP] Basic switch statement

2010-04-14 Thread Ashley Sheridan
On Wed, 2010-04-14 at 16:52 -0400, Paul M Foster wrote:

> On Wed, Apr 14, 2010 at 12:28:13PM -0400, tedd wrote:
> 
> > At 5:06 PM -0400 4/13/10, Robert Cummings wrote:
> >> Nathan Rixham wrote:
> >>>
> >>> well that's one job I'm not getting :p
> >>
> >> Well you DID get 66.7%. I've met "coders" that would stare at the
> >> answer and still not understand :D
> >>
> >> Cheers,
> >> Rob.
> >
> > Well.. count me among those staring. I just don't get those type of
> > things until I see them actually work.
> >
> > My "logic" works the other way -- when presented with a logic
> > problem, I come up with a solution that works the way I think and I
> > always to solve the problem presented. Perhaps my solution isn't as
> > clever nor as cryptic as others, but it's always easier to read and
> > understand.
> 
> +1
> 
> I've never had other coders looking over my shoulder, and I agonized for
> years over whether my logical solutions were the "best" approach. Now I
> just code and take pride in the fact that I can understand what I did
> later (mostly).
> 
> Paul
> 
> -- 
> Paul M. Foster
> 


I think as long as the code is readable, and doesn't have any glaringly
obvious issues (I've seen people re-writing built in PHP functionality
because they didn't know the built-in function existed) then it should
be OK. Add comments to aid any areas where you think you might forget or
other people might not easily understand what is happening.

Don't get me wrong, clever ideas are nice, and sometimes with the right
comment they just work beautifully. Just occassionally though something
is done in such a neat clever way, that in the future when it comes time
to extend the system, this neat clever idea is actually a hindrance and
causes extra work because it has to be re-written a 'less-clever' but
more flexible way!

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Basic switch statement

2010-04-14 Thread Paul M Foster
On Wed, Apr 14, 2010 at 10:06:39PM +0100, Ashley Sheridan wrote:

> On Wed, 2010-04-14 at 16:52 -0400, Paul M Foster wrote:



> 
> 
> I've never had other coders looking over my shoulder, and I agonized for
> years over whether my logical solutions were the "best"
> approach. Now I
> just code and take pride in the fact that I can understand what I did
> later (mostly).
> 
> Paul
> 
> --
> Paul M. Foster
> 
> 
> 
> I think as long as the code is readable, and doesn't have any glaringly 
> obvious
> issues (I've seen people re-writing built in PHP functionality because they
> didn't know the built-in function existed) then it should be OK. Add comments
> to aid any areas where you think you might forget or other people might not
> easily understand what is happening.
> 
> Don't get me wrong, clever ideas are nice, and sometimes with the right 
> comment
> they just work beautifully. Just occassionally though something is done in 
> such
> a neat clever way, that in the future when it comes time to extend the system,
> this neat clever idea is actually a hindrance and causes extra work because it
> has to be re-written a 'less-clever' but more flexible way!

That reminds me of a story. I once wrote what was almost an RPG (RPG--
the language, not the game) interpeter under FoxPro to handle incoming
EDI traffic and update invoicing, etc. The big problem with EDI is that
no one follows the standards properly, so every vendor tendering an
invoice did it differently. So you needed a database driven system which
would selectively make decisions based on each line of incoming EDI
content. Worked great, and when a new vendor came along, you just
analyzed their transactions and populated some more records in the
database to handle that vendor's transactions. I know, it sounds
obscure, but it made perfect sense at the time.

Shortly after that, I left that company. I documented the system, and it
worked fine, but it was hard to wrap your wits around how it worked. And
I just know the next coder on that account was cursing me day and night
for writing that system. 

Anyway...

Paul

-- 
Paul M. Foster

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