php-general Digest 15 Sep 2010 13:15:56 -0000 Issue 6942
Topics (messages 308075 through 308101):
Re: Adjusting Session Times
308075 by: Nathan Rixham
308076 by: Nathan Rixham
Re: Question about news.php.net
308077 by: Daniel Brown
308082 by: Gary
308083 by: MikeB
Re: php cli question
308078 by: Nathan Rixham
308080 by: J Ravi Menon
308097 by: Bostjan Skufca
Re: 1984 (Big Brother)
308079 by: Nathan Rixham
308101 by: Marc Guay
Re: Could this be a bug?
308081 by: Thijs Lensselink
Xpath arguments in variable
308084 by: Sridhar Pandurangiah
308086 by: Ashley Sheridan
308087 by: Gary
308088 by: Sridhar Pandurangiah
308089 by: Sridhar Pandurangiah
308090 by: Sridhar Pandurangiah
308091 by: Ashley Sheridan
308092 by: Pete Ford
308093 by: Pete Ford
308094 by: Pete Ford
308095 by: Sridhar Pandurangiah
308096 by: Ashley Sheridan
libmcrypt usage
308085 by: Gary
How to store data that doesn't change?
308098 by: Peter van der Does
308099 by: Peter Lind
308100 by: Ashley Sheridan
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 ---
Floyd Resler wrote:
We just got a client whose requirement is that user sessions expire after 30
minutes of inactivity. Our other clients are happy with not having their
sessions expire during the work day (i.e. life is 8 hours). I am using a MySQL
database to store the session data. My thought is to adjust the session
expiration in the table based on the client currently logged in. Is this a
good approach or would there be better ways to do it? And just to clarify: all
clients use the same Web site.
It may be worth storing sessions in something like redis [1] instead,
which let's you expire data [2] after a given time, then you can
configure however you want easily.
The other benefit is that sessions will be extremely fast given that
they'll all be stored in ram :)
[1] http://code.google.com/p/redis/
[2] http://code.google.com/p/redis/wiki/ExpireCommand
Best,
Nathan
--- End Message ---
--- Begin Message ---
Floyd Resler wrote:
We just got a client whose requirement is that user sessions expire after 30
minutes of inactivity. Our other clients are happy with not having their
sessions expire during the work day (i.e. life is 8 hours). I am using a MySQL
database to store the session data. My thought is to adjust the session
expiration in the table based on the client currently logged in. Is this a
good approach or would there be better ways to do it? And just to clarify: all
clients use the same Web site.
It may be worth storing sessions in something like redis [1] instead,
which let's you expire data [2] after a given time, then you can
configure however you want easily.
The other benefit is that sessions will be extremely fast given that
they'll all be stored in ram :)
[1] http://code.google.com/p/redis/
[2] http://code.google.com/p/redis/wiki/ExpireCommand
Best,
Nathan
--- End Message ---
--- Begin Message ---
Good to know there's a workaround. I am thinking of using one (or more) of
the old VOOM boxes to mirror the news server for NNTP-only access.
Sent from my DROID. Apologies if formatting is off or I'm top-posting on a
list.
On Sep 14, 2010 8:59 PM, "Nathan Rixham" <[email protected]> wrote:
> Daniel Brown wrote:
>> On Mon, Sep 13, 2010 at 18:09, MikeB <[email protected]> wrote:
>>> However, getting access seems to be hit-and-miss, since I more often
than
>>> not get a message that the connection to news.php.net timed out.
>>>
>>> Is this an indication that the server is just very busy? I don't get
this on
>>> any other news server I'm using on the smae news reader and I have
gotten
>>> this on two different news readers that I have tried.
>>
>> I don't believe that we've been having any issues with the server,
>> no. Are you using NNTP to connect? You may want to consider using
>> the HTTP-based RSS and/or RDF feeds if it continues to be an issue.
>> In addition, if you continue to have problems, file a bug report at
>> http://bugs.php.net/ and we'll look into it further.
>
> Dan, Mike,
>
> I can confirm this happens "all the time" in thunderbird, and always has
> for many years now, on all PHP NNTP lists.
>
> However, the problem can be worked around simply, for some reason the
> timeout generally only happens with the first call to view a mailing
> list, after X minutes of inactivity. Thus, I simply subscribe to a few
> different PHP lists (like .soap .test and general) then when I open
> thunderbird I quickly click a list I *don't* want to see, then click on
> .general, .general then loads nicely as expected letting the other one
> timeout :)
>
> It's hardly a fix, but it works - may be worth checking if this is the
> case with the latest thunderbird revision and then reporting it as a
> "bug" (in either thunderbird or the mailing list software that PHP is
> running).
>
> Best,
>
> Nathan
--- End Message ---
--- Begin Message ---
MikeB wrote:
> I understand that the news server is based on a mailing list, but I
> can't handle another high-volume source dumping stuff into my email
> (even if I filter it into a separate folder) so I am trying to subscribe
> through the news group.
>
> However, getting access seems to be hit-and-miss, since I more often
> than not get a message that the connection to news.php.net timed out.
Tried nntp://news.gmane.org/gmane.comp.php.general ?
--
Gary Please do NOT send me 'courtesy' replies off-list.
PHP 5.2.12 (cli) (built: Jan 14 2010 14:54:11)
1.7.7(0.230/5/3) 2010-08-31 09:58 Cygwin
--- End Message ---
--- Begin Message ---
Gary wrote:
MikeB wrote:
I understand that the news server is based on a mailing list, but I
can't handle another high-volume source dumping stuff into my email
(even if I filter it into a separate folder) so I am trying to subscribe
through the news group.
However, getting access seems to be hit-and-miss, since I more often
than not get a message that the connection to news.php.net timed out.
Tried nntp://news.gmane.org/gmane.comp.php.general ?
Bingo! Thanks!
--- End Message ---
--- Begin Message ---
Per Jessen wrote:
J Ravi Menon wrote:
2) What about garbage collection? In a standard apache-mod-php
setup, we rely on the end of a request-cycle to free up resources -
close file descriptiors, free up memory etc..
I am assuming in the aforesaid standalone daemon case, we would
have to do this manually?
Yes.
So 'unset($some_big_array)' or 'unset($some_big_object)' etc.. is the
right way to go for non-resource based items? i.e. it needs to be
explicitly done?
It's not quite like C - if you reassign something, the previous contents
are automagically freed. I use unset() if I know it could be a while
(hours) before it'll likely be reassigned, but it won't be used in the
meantime.
Has anybody done a comparison of setting to null rather than unset'ing;
does unset invoke the garbage collector instantly? i.e. is unset the
best approach to clearing objects from memory quickly?
Best,
Nathan
--- End Message ---
--- Begin Message ---
On Tue, Sep 14, 2010 at 1:15 PM, Per Jessen <[email protected]> wrote:
> J Ravi Menon wrote:
>
>> On Tue, Sep 14, 2010 at 12:43 AM, Per Jessen <[email protected]> wrote:
>>> J Ravi Menon wrote:
>>>
>>>> Few questions:
>>>>
>>>> 1) Does opcode cache really matter in such cli-based daemons? As
>>>> 'SomeClass' is instantiated at every loop, I am assuming it is only
>>>> compiled once as it has already been 'seen'.
>>>
>>> Yup.
>>
>> Just to clarify, you mean we don't need the op-code cache here right?
>
> That is correct.
>
>>>> 2) What about garbage collection? In a standard apache-mod-php
>>>> setup, we rely on the end of a request-cycle to free up resources -
>>>> close file descriptiors, free up memory etc..
>>>> I am assuming in the aforesaid standalone daemon case, we would
>>>> have to do this manually?
>>>
>>> Yes.
>>
>> So 'unset($some_big_array)' or 'unset($some_big_object)' etc.. is the
>> right way to go for non-resource based items? i.e. it needs to be
>> explicitly done?
>
> It's not quite like C - if you reassign something, the previous contents
> are automagically freed. I use unset() if I know it could be a while
> (hours) before it'll likely be reassigned, but it won't be used in the
> meantime.
>
Thanks Per for clarifying this for me. Now on my follow up question:
[Note: I think it is related to the issues discussed above hence
keeping it on this thread but if I am violating any guidelines here,
do let me know]
One reason the aforesaid questions got triggered was that in our
company right now, there is a big discussion on moving away from
apache+mod_php solution to nginx+fast-cgi based model for handling all
php-based services. The move seems to be more based some anecdotal
observations and possibly not based on a typical php-based app (i.e.
the php script involved was trivial one acting as some proxy to
another backend service).
I have written fast-cgi servers in the past in C++, and I am aware how
the apahce<---->fast-cgi-servers work (in unix socket setups). All
our php apps are written with apache+mod_php in mind (no explicit
resource mgmt ), so this was a concern to me.
If the same scripts now need to run 'forever' as a fastcgi server, are
we forced to do such manual resource mgmt? Or are there solutions here
that work just as in mod_php?
This reminded me of the cli daemons that I had written earlier where
such manual cleanups were done, and hence my doubts on this
nginx+fast-cgi approach.
thx,
Ravi
>
>
> --
> Per Jessen, Zürich (14.6°C)
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Here are the results I got when question of migration from apache to nginx
was brought up:
http://blog.a2o.si/2009/06/24/apache-mod_php-compared-to-nginx-php-fpm/
(BTW there is some FPM in main PHP distribution now)
As for resource management, I recommend looking at php sources
(Zend/zend_alloca.c:zend_mm_shutdown() specifically) and building a custom
extension that frees discarded memory resources on your request or timer or
sth else. Not sure if it is possible like that but this is just a
suggestion, don't quote me on that :)
Also, for such questions I recommend you to join php-internals mailing list,
it seems more appropriate.
b.
On 15 September 2010 04:19, J Ravi Menon <[email protected]> wrote:
> On Tue, Sep 14, 2010 at 1:15 PM, Per Jessen <[email protected]> wrote:
> > J Ravi Menon wrote:
> >
> >> On Tue, Sep 14, 2010 at 12:43 AM, Per Jessen <[email protected]> wrote:
> >>> J Ravi Menon wrote:
> >>>
> >>>> Few questions:
> >>>>
> >>>> 1) Does opcode cache really matter in such cli-based daemons? As
> >>>> 'SomeClass' is instantiated at every loop, I am assuming it is only
> >>>> compiled once as it has already been 'seen'.
> >>>
> >>> Yup.
> >>
> >> Just to clarify, you mean we don't need the op-code cache here right?
> >
> > That is correct.
> >
> >>>> 2) What about garbage collection? In a standard apache-mod-php
> >>>> setup, we rely on the end of a request-cycle to free up resources -
> >>>> close file descriptiors, free up memory etc..
> >>>> I am assuming in the aforesaid standalone daemon case, we would
> >>>> have to do this manually?
> >>>
> >>> Yes.
> >>
> >> So 'unset($some_big_array)' or 'unset($some_big_object)' etc.. is the
> >> right way to go for non-resource based items? i.e. it needs to be
> >> explicitly done?
> >
> > It's not quite like C - if you reassign something, the previous contents
> > are automagically freed. I use unset() if I know it could be a while
> > (hours) before it'll likely be reassigned, but it won't be used in the
> > meantime.
> >
>
> Thanks Per for clarifying this for me. Now on my follow up question:
>
> [Note: I think it is related to the issues discussed above hence
> keeping it on this thread but if I am violating any guidelines here,
> do let me know]
>
> One reason the aforesaid questions got triggered was that in our
> company right now, there is a big discussion on moving away from
> apache+mod_php solution to nginx+fast-cgi based model for handling all
> php-based services. The move seems to be more based some anecdotal
> observations and possibly not based on a typical php-based app (i.e.
> the php script involved was trivial one acting as some proxy to
> another backend service).
>
> I have written fast-cgi servers in the past in C++, and I am aware how
> the apahce<---->fast-cgi-servers work (in unix socket setups). All
> our php apps are written with apache+mod_php in mind (no explicit
> resource mgmt ), so this was a concern to me.
>
> If the same scripts now need to run 'forever' as a fastcgi server, are
> we forced to do such manual resource mgmt? Or are there solutions here
> that work just as in mod_php?
>
> This reminded me of the cli daemons that I had written earlier where
> such manual cleanups were done, and hence my doubts on this
> nginx+fast-cgi approach.
>
> thx,
> Ravi
>
>
> >
> >
> > --
> > Per Jessen, Zürich (14.6°C)
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Daniel Brown wrote:
On Mon, Sep 13, 2010 at 19:47, Micky Hulse <[email protected]> wrote:
Motion sensing camera connected to a mechanical pointer stick aimed to
trigger the server power button.
On his way out of the office:
Clap on/clap off Clapper connected to computer power cable.
It would be cheaper to employ the same method used on some
lawnmowers and required on Jet Skis and Skidoos: a cable with a clip
worn by the rider. The rider falls off, the cable releases from the
vehicle, disengaging the throttle and cutting the engine. The boss
stands up, his entire infrastructure collapses, everyone's connections
are closed, and all PCs subsequently catch fire.
I fear this is the implementation needed to make "boss" see sense, however..
Realistically, a simple desktop-based application running in the
system tray (presuming Windows) would send a kill signal to a
predefined script to issue safe closing routines to the database
first, then any other systems he wants to close out. It could even
have simple options to poll if there's a screensaver activated, which
would initiate the process automatically, should he choose to be
extremely paranoid. The same could be automated to work in reverse,
to automatically bring the systems up, when the local desktop session
becomes active (from hibernation, logoff, or screensaver), or even
with an override ("Pause Sessions") by right-clicking the systray
icon.
The main problem here is in using a stateless protocol (HTTP) in a
stateful manner (with sessions), it makes this, technically, impossible.
That said, you could do this in a stateless manner quite easily by
giving the boss full control of granting and denying access, that way he
is always accountable (with his described nature, it might be good for
the buck to stop with him, rather than your code). I'd suggest having a
simple boolean flag, usersCanAccess and giving him a button to toggle
the flags state from true to false. Real life implementation could be an
empty file which is `touch`ed and `unlink`ed, php implementation being
an if(file_exists('boss_man_say_okay') ){ // let monkeys work } type
solution.
Best,
Nathan
--- End Message ---
--- Begin Message ---
> if(file_exists('boss_man_say_okay') ){ // let monkeys work }
Is there an acronym for the sound of sad, knowing laughter?
--- End Message ---
--- Begin Message ---
On 09/14/2010 11:31 PM, Camilo Sperberg wrote:
On Tue, Sep 14, 2010 at 02:46, Thijs Lensselink<[email protected]> wrote:
On 09/14/2010 08:33 AM, Thijs Lensselink wrote:
On 09/14/2010 12:16 AM, Camilo Sperberg wrote:
I have some really strange behaviour going on here, and I think it could
be
a (minor) PHP's bug.
I am not really sure about what happens internally, but my best guess
would
be that after a memory exhaustion, when I try to execute a custom error
handler with the register_shutdown_function (which is executed even after
a
fatal error) and try to access the element that provoked the memory
exhaustion, no error should raise instead of *Uninitialized string
offset:
0.
I have prepared a little test case to reproduce the error and (I hope)
can
explain the error.
<?php
date_default_timezone_set('America/Santiago');
ini_set('memory_limit','1M');
ini_set('display_errors',1);
error_reporting(-1);
function my_error_handler($errno = '0', $errstr = '[FATAL] General
Error',
$errfile = 'N/A', $errline = 'N/A', $errctx = '') {
This seems to be your error. You set $errctx to be a string. But later on
you use it as an array.
Remove the = '' part. And it will function as expected.
You're right... However I don't like leaving non-default value in functions
so I did something like if(empty($errctx)) $errctx = array() in the first
line of the custom error handler which threw out the error message and
everything works ok now.
I think from 5.2 and up you can use the array keyword to force an array
as parameter..
But -and correct me if I'm wrong- isn't isset (or empty) supposed to return
a FALSE whenever that variable doesn't exist?
With your help, I could reduce the test case into:
$asdf = 'hello world';
if (empty($asdf[4]['inventing'])) echo 'nice little world';
if (isset($asdf['inventing'][6])) echo 'little nice world';
// This works ok.
This works because the string $asdf is set with a value. So $asdf[4]
exists but ['inventing'] doesn't so it will return false
$asdf = '';
if (empty($asdf[4]['inventing'])) echo 'nice little world';
if (isset($asdf['inventing'][6])) echo 'little nice world';
// This returns E_NOTICE
This doesn't work because the string $asdf is empty. So calling $asdf[4]
will trigger a notice since there is no 4th character
Shouldn't these 2 examples work exactly the same way? (AKA as Nº 1). If
not... why not? Both are string types, onyl difference is that one has no
characters in it while the other does, but essentialy they are both the
same.
Greetings !
--- End Message ---
--- Begin Message ---
Hi
I have the following statement that locates the node "membernumber" with
the value A192. This works perfectly fine.
$v = $row->xpath('//membernumber[. = "A192"]');
But now I need to pass this value to XPath within a string variable say
$v = $row->xpath('//membernumber[. = $MemberId]');
But this doesnt work due to the quotes. What I intend PHP to do is to
substitute the value for $MemberId and then execute the XPath query. I
have grappled with it for a few days before posting this. Any ideas are
most welcome
Best regards
Sridhar
--- End Message ---
--- Begin Message ---
On Wed, 2010-09-15 at 13:06 +0530, Sridhar Pandurangiah wrote:
> Hi
>
> I have the following statement that locates the node "membernumber" with
> the value A192. This works perfectly fine.
>
> $v = $row->xpath('//membernumber[. = "A192"]');
>
> But now I need to pass this value to XPath within a string variable say
>
> $v = $row->xpath('//membernumber[. = $MemberId]');
>
> But this doesnt work due to the quotes. What I intend PHP to do is to
> substitute the value for $MemberId and then execute the XPath query. I
> have grappled with it for a few days before posting this. Any ideas are
> most welcome
>
> Best regards
>
> Sridhar
>
Use double quotes instead, which should allow PHP to expand the
variables.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
Sridhar Pandurangiah wrote:
> now I need to pass this value to XPath within a string variable say
>
> $v = $row->xpath('//membernumber[. = $MemberId]');
>
> But this doesnt work due to the quotes. What I intend PHP to do is to
> substitute the value for $MemberId and then execute the XPath query. I
> have grappled with it for a few days before posting this.
Whats wrong with
$v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
?
Am I not understanding what you are trying to ask?
--
Gary Please do NOT send me 'courtesy' replies off-list.
PHP 5.2.12 (cli) (built: Jan 14 2010 14:54:11)
1.7.7(0.230/5/3) 2010-08-31 09:58 Cygwin
--- End Message ---
--- Begin Message ---
-------- Original Message --------
Subject: Re: Xpath arguments in variable
From: [email protected] (Gary)
To:
Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST)
Whats wrong with
$v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
?
Am I not understanding what you are trying to ask?
--------------------
I tried this but doesn't work. I guess the above statement is
concatenating the entire string and the substitution isn't happening
What I am trying to do is as follows
$MemberId = 'A192';
$v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
The $MemberId should be substituted with A192 and then the xpath query
should be executed. The result should be that I locate the membernumber
XML element that has the value A912.
Best regards
Sridhar
Sridhar Pandurangiah wrote:
now I need to pass this value to XPath within a string variable say
$v = $row->xpath('//membernumber[. = $MemberId]');
But this doesnt work due to the quotes. What I intend PHP to do is to
substitute the value for $MemberId and then execute the XPath query. I
have grappled with it for a few days before posting this.
Whats wrong with
$v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
?
Am I not understanding what you are trying to ask?
--- End Message ---
--- Begin Message ---
-------- Original Message --------
Subject: Re: Xpath arguments in variable
From: [email protected] (Gary)
To:
Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST)
Whats wrong with
$v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
?
Am I not understanding what you are trying to ask?
--------------------
I tried this but doesn't work. I guess the above statement is
concatenating the entire string and the substitution isn't happening
What I am trying to do is as follows
$MemberId = 'A192';
$v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
The $MemberId should be substituted with A192 and then the xpath query
should be executed. The result should be that I locate the membernumber
XML element that has the value A912.
Best regards
Sridhar
Sridhar Pandurangiah wrote:
now I need to pass this value to XPath within a string variable say
$v = $row->xpath('//membernumber[. = $MemberId]');
But this doesnt work due to the quotes. What I intend PHP to do is to
substitute the value for $MemberId and then execute the XPath query. I
have grappled with it for a few days before posting this.
Whats wrong with
$v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
?
Am I not understanding what you are trying to ask?
--- End Message ---
--- Begin Message ---
-------- Original Message --------
Subject: Re: Xpath arguments in variable
From: [email protected] (Gary)
To:
Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST)
Whats wrong with
$v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
?
Am I not understanding what you are trying to ask?
--------------------
I tried this but doesn't work. I guess the above statement is
concatenating the entire string and the substitution isn't happening
What I am trying to do is as follows
$MemberId = 'A192';
$v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
The $MemberId should be substituted with A192 and then the xpath query
should be executed. The result should be that I locate the membernumber
XML element that has the value A912.
Best regards
Sridhar
Sridhar Pandurangiah wrote:
now I need to pass this value to XPath within a string variable say
$v = $row->xpath('//membernumber[. = $MemberId]');
But this doesnt work due to the quotes. What I intend PHP to do is to
substitute the value for $MemberId and then execute the XPath query. I
have grappled with it for a few days before posting this.
Whats wrong with
$v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
?
Am I not understanding what you are trying to ask?
--- End Message ---
--- Begin Message ---
On Wed, 2010-09-15 at 14:03 +0530, Sridhar Pandurangiah wrote:
> -------- Original Message --------
> Subject: Re: Xpath arguments in variable
> From: [email protected] (Gary)
> To:
> Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST)
>
> Whats wrong with
> $v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
> ?
>
> Am I not understanding what you are trying to ask?
>
> --------------------
>
> I tried this but doesn't work. I guess the above statement is
> concatenating the entire string and the substitution isn't happening
>
> What I am trying to do is as follows
> $MemberId = 'A192';
> $v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
>
> The $MemberId should be substituted with A192 and then the xpath query
> should be executed. The result should be that I locate the membernumber
> XML element that has the value A912.
>
> Best regards
>
> Sridhar
>
>
> > Sridhar Pandurangiah wrote:
> >> now I need to pass this value to XPath within a string variable say
> >>
> >> $v = $row->xpath('//membernumber[. = $MemberId]');
> >>
> >> But this doesnt work due to the quotes. What I intend PHP to do is to
> >> substitute the value for $MemberId and then execute the XPath query. I
> >> have grappled with it for a few days before posting this.
> >
> > Whats wrong with
> > $v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
> > ?
> >
> > Am I not understanding what you are trying to ask?
> >
>
Did you try using double quotes?
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
If you needed the double-quotes in the Xpath expression when the constant is
used , then you probably need them in the variable version.
$v = $row->xpath('//membernumber[. = "'.$MemberId.'"]');
That should put the double-quotes in for you...
On 15/09/10 09:33, Sridhar Pandurangiah wrote:
-------- Original Message --------
Subject: Re: Xpath arguments in variable
From: [email protected] (Gary)
To:
Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST)
Whats wrong with
$v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
?
Am I not understanding what you are trying to ask?
--------------------
I tried this but doesn't work. I guess the above statement is
concatenating the entire string and the substitution isn't happening
What I am trying to do is as follows
$MemberId = 'A192';
$v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
The $MemberId should be substituted with A192 and then the xpath query
should be executed. The result should be that I locate the membernumber
XML element that has the value A912.
Best regards
Sridhar
Sridhar Pandurangiah wrote:
now I need to pass this value to XPath within a string variable say
$v = $row->xpath('//membernumber[. = $MemberId]');
But this doesnt work due to the quotes. What I intend PHP to do is to
substitute the value for $MemberId and then execute the XPath query. I
have grappled with it for a few days before posting this.
Whats wrong with $v = $row->xpath('//membernumber[. = ' . $MemberId .
']');
?
Am I not understanding what you are trying to ask?
--
Peter Ford, Developer phone: 01580 893333 fax: 01580 893399
Justcroft International Ltd. www.justcroft.com
Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom
Registered in England and Wales: 2297906
Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS
--- End Message ---
--- Begin Message ---
If you needed the double-quotes in the Xpath expression when the constant is
used , then you probably need them in the variable version.
$v = $row->xpath('//membernumber[. = "'.$MemberId.'"]');
That should put the double-quotes in for you...
On 15/09/10 09:33, Sridhar Pandurangiah wrote:
-------- Original Message --------
Subject: Re: Xpath arguments in variable
From: [email protected] (Gary)
To:
Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST)
Whats wrong with
$v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
?
Am I not understanding what you are trying to ask?
--------------------
I tried this but doesn't work. I guess the above statement is
concatenating the entire string and the substitution isn't happening
What I am trying to do is as follows
$MemberId = 'A192';
$v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
The $MemberId should be substituted with A192 and then the xpath query
should be executed. The result should be that I locate the membernumber
XML element that has the value A912.
Best regards
Sridhar
Sridhar Pandurangiah wrote:
now I need to pass this value to XPath within a string variable say
$v = $row->xpath('//membernumber[. = $MemberId]');
But this doesnt work due to the quotes. What I intend PHP to do is to
substitute the value for $MemberId and then execute the XPath query. I
have grappled with it for a few days before posting this.
Whats wrong with $v = $row->xpath('//membernumber[. = ' . $MemberId .
']');
?
Am I not understanding what you are trying to ask?
--
Peter Ford, Developer phone: 01580 893333 fax: 01580 893399
Justcroft International Ltd. www.justcroft.com
Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom
Registered in England and Wales: 2297906
Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS
--- End Message ---
--- Begin Message ---
If you needed the double-quotes in the Xpath expression when the constant is
used , then you probably need them in the variable version.
$v = $row->xpath('//membernumber[. = "'.$MemberId.'"]');
That should put the double-quotes in for you...
On 15/09/10 09:33, Sridhar Pandurangiah wrote:
-------- Original Message --------
Subject: Re: Xpath arguments in variable
From: [email protected] (Gary)
To:
Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST)
Whats wrong with
$v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
?
Am I not understanding what you are trying to ask?
--------------------
I tried this but doesn't work. I guess the above statement is
concatenating the entire string and the substitution isn't happening
What I am trying to do is as follows
$MemberId = 'A192';
$v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
The $MemberId should be substituted with A192 and then the xpath query
should be executed. The result should be that I locate the membernumber
XML element that has the value A912.
Best regards
Sridhar
Sridhar Pandurangiah wrote:
now I need to pass this value to XPath within a string variable say
$v = $row->xpath('//membernumber[. = $MemberId]');
But this doesnt work due to the quotes. What I intend PHP to do is to
substitute the value for $MemberId and then execute the XPath query. I
have grappled with it for a few days before posting this.
Whats wrong with $v = $row->xpath('//membernumber[. = ' . $MemberId .
']');
?
Am I not understanding what you are trying to ask?
--
Peter Ford, Developer phone: 01580 893333 fax: 01580 893399
Justcroft International Ltd. www.justcroft.com
Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom
Registered in England and Wales: 2297906
Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS
--- End Message ---
--- Begin Message ---
Managed to resolve it. Phew!
$v = $row->xpath('//membernumber[. = ' . '"' . $MemberId . '"' . ']');
works.
Best regards
Sridhar
-------- Original Message --------
Subject: Re: [PHP] Re: Xpath arguments in variable
From: [email protected] (Ashley Sheridan)
To:
Date: Wed Sep 15 2010 14:04:33 GMT+0530 (IST)
On Wed, 2010-09-15 at 14:03 +0530, Sridhar Pandurangiah wrote:
-------- Original Message --------
Subject: Re: Xpath arguments in variable
From: [email protected] (Gary)
To:
Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST)
Whats wrong with
$v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
?
Am I not understanding what you are trying to ask?
--------------------
I tried this but doesn't work. I guess the above statement is
concatenating the entire string and the substitution isn't happening
What I am trying to do is as follows
$MemberId = 'A192';
$v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
The $MemberId should be substituted with A192 and then the xpath query
should be executed. The result should be that I locate the membernumber
XML element that has the value A912.
Best regards
Sridhar
Sridhar Pandurangiah wrote:
now I need to pass this value to XPath within a string variable say
$v = $row->xpath('//membernumber[. = $MemberId]');
But this doesnt work due to the quotes. What I intend PHP to do is to
substitute the value for $MemberId and then execute the XPath query. I
have grappled with it for a few days before posting this.
Whats wrong with
$v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
?
Am I not understanding what you are trying to ask?
Did you try using double quotes?
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On Wed, 2010-09-15 at 14:27 +0530, Sridhar Pandurangiah wrote:
> Managed to resolve it. Phew!
>
> $v = $row->xpath('//membernumber[. = ' . '"' . $MemberId . '"' . ']');
>
> works.
>
> Best regards
>
> Sridhar
>
>
> -------- Original Message --------
> Subject: Re: [PHP] Re: Xpath arguments in variable
> From: [email protected] (Ashley Sheridan)
> To:
> Date: Wed Sep 15 2010 14:04:33 GMT+0530 (IST)
>
> > On Wed, 2010-09-15 at 14:03 +0530, Sridhar Pandurangiah wrote:
> >
> >> -------- Original Message --------
> >> Subject: Re: Xpath arguments in variable
> >> From: [email protected] (Gary)
> >> To:
> >> Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST)
> >>
> >> Whats wrong with
> >> $v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
> >> ?
> >>
> >> Am I not understanding what you are trying to ask?
> >>
> >> --------------------
> >>
> >> I tried this but doesn't work. I guess the above statement is
> >> concatenating the entire string and the substitution isn't happening
> >>
> >> What I am trying to do is as follows
> >> $MemberId = 'A192';
> >> $v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
> >>
> >> The $MemberId should be substituted with A192 and then the xpath query
> >> should be executed. The result should be that I locate the membernumber
> >> XML element that has the value A912.
> >>
> >> Best regards
> >>
> >> Sridhar
> >>
> >>
> >>> Sridhar Pandurangiah wrote:
> >>>> now I need to pass this value to XPath within a string variable say
> >>>>
> >>>> $v = $row->xpath('//membernumber[. = $MemberId]');
> >>>>
> >>>> But this doesnt work due to the quotes. What I intend PHP to do is to
> >>>> substitute the value for $MemberId and then execute the XPath query. I
> >>>> have grappled with it for a few days before posting this.
> >>> Whats wrong with
> >>> $v = $row->xpath('//membernumber[. = ' . $MemberId . ']');
> >>> ?
> >>>
> >>> Am I not understanding what you are trying to ask?
> >>>
> >
> >
> > Did you try using double quotes?
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >
>
Wouldn't
$v = $row->xpath('//membernumber[. = "' . $MemberId . '"]');
be better? You're breaking the string into too many parts for now
reason.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
Can anyone tell me what the equivalent to the following command line
usage of openssl is, in php using the mcrypt_* functions, please:
,----
| openssl enc -e -aes-256-cbc -k <some key> ...
`----
TIA.
I tried
,----
| $iv = mcrypt_create_iv(mcrypt_get_block_size(MCRYPT_RIJNDAEL_256,
| MCRYPT_MODE_CBC),
| MCRYPT_DEV_RANDOM);
| $encryptedData = mcrypt_cbc(MCRYPT_RIJNDAEL_256
| ,$passphrase
| ,$data
| ,MCRYPT_ENCRYPT
| ,$iv);
`----
amongst other things, but it doesn't work, I get "bad magic number"
when I tried to decrypt the contents of $encryptedData using
,----
| openssl enc -d -aes-256-cbc -k <passphrase> ...
`----
Yeah, bad magic number, naughty magic number, go and stand in the
corner. Seriously. WTH is that supposed to mean?!
I also tried not using an iv but mcrypt slapped my wrist for trying it.
--
Gary Please do NOT send me 'courtesy' replies off-list.
PHP 5.2.12 (cli) (built: Jan 14 2010 14:54:11)
1.7.7(0.230/5/3) 2010-08-31 09:58 Cygwin
--- End Message ---
--- Begin Message ---
Hi,
How do you people store data that doesn't change, an example of this
would be the version number of your software. You might want to use it
through out your program but how to you store it?
As far as I can see there are several options to use this data.
1. Global Variable
2. Store it in a registry class
3. Store it in a named constant.
4. Use a function that will return the data (kind of like a regsitry
class but it's not a class)
Personally I don't like option 1 but what about the other options. Is
any of them faster then the others. What other pros and cons are there.
--
Peter van der Does
GPG key: E77E8E98
IRC: Ganseki on irc.freenode.net
Twitter: @petervanderdoes
WordPress Plugin Developer
Blog: http://blog.avirtualhome.com
Forums: http://forums.avirtualhome.com
Twitter: @avhsoftware
--- End Message ---
--- Begin Message ---
On 15 September 2010 14:46, Peter van der Does <[email protected]> wrote:
> Hi,
>
> How do you people store data that doesn't change, an example of this
> would be the version number of your software. You might want to use it
> through out your program but how to you store it?
>
> As far as I can see there are several options to use this data.
> 1. Global Variable
> 2. Store it in a registry class
> 3. Store it in a named constant.
> 4. Use a function that will return the data (kind of like a regsitry
> class but it's not a class)
>
> Personally I don't like option 1 but what about the other options. Is
> any of them faster then the others. What other pros and cons are there.
>
3. Constant, as long as you're dealing with scalars.
Regards
Peter
--
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
</hype>
--- End Message ---
--- Begin Message ---
On Wed, 2010-09-15 at 08:46 -0400, Peter van der Does wrote:
> Hi,
>
> How do you people store data that doesn't change, an example of this
> would be the version number of your software. You might want to use it
> through out your program but how to you store it?
>
> As far as I can see there are several options to use this data.
> 1. Global Variable
> 2. Store it in a registry class
> 3. Store it in a named constant.
> 4. Use a function that will return the data (kind of like a regsitry
> class but it's not a class)
>
> Personally I don't like option 1 but what about the other options. Is
> any of them faster then the others. What other pros and cons are there.
>
> --
> Peter van der Does
>
> GPG key: E77E8E98
>
> IRC: Ganseki on irc.freenode.net
> Twitter: @petervanderdoes
>
> WordPress Plugin Developer
> Blog: http://blog.avirtualhome.com
> Forums: http://forums.avirtualhome.com
> Twitter: @avhsoftware
>
I'd go with a constant, for the simple reason that it means the variable
can't and shouldn't change in the execution of the script. The constant
could be within a class or a global, however you prefer. There will be
slightly more memory used in a class, but it avoids the constant from
conflicting with others in the script possibly.
Creating a whole function or class for this does seem a little overkill
probably, so a simple global constant should do the job really.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---