Re: [PHP] Please help with glob

2011-04-04 Thread Al Mangkok
Hi Louis,
Yes, I have read that glob is only available for PHP > 4.3 and I am
using version 5.2.1.7

# /usr/local/bin/php -v
PHP 5.2.17 (cli) (built: Feb 16 2011 15:41:35)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies




# /usr/local/bin/php globtest.php

Fatal error: Call to undefined function  glob() in
/usr/local/apache2/htdocs/hrms/globtest.php on line 2



I have read somewhere that it could be connected to glibc, not I have
no idea how to fix that. Anyone ?


--
al



On Tue, Apr 5, 2011 at 2:25 PM, Louis Huppenbauer
 wrote:
> Hi there
>
> Since glob is actually a part of the core - Are you absolutely sure
> that you're running PHP > 4.3
>
> 2011/4/5 Al Mangkok :
>> Hi everyone,
>> I am very new to PHP and trying to learn the glob() function. I copied
>> the example on php.net :
>>
>> > foreach (glob("*.txt") as $filename) {
>>    echo "$filename size " . filesize($filename) . "\n";
>> }
>> ?>
>>
>> When I ran the script, I got this error message:
>> Fatal error: Call to undefined function  glob() in
>> /usr/local/apache2/htdocs/hrms/globtest.php on line 2
>>
>> I am running PHP 5.2.17 on CentOS 4.8 . How do I compile PHP to get
>> the glob function in ?
>> Please help.
>>
>>
>> --
>> al
>>
>> --
>> 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



Re: [PHP] Please help with glob

2011-04-04 Thread Louis Huppenbauer
Hi there

Since glob is actually a part of the core - Are you absolutely sure
that you're running PHP > 4.3

2011/4/5 Al Mangkok :
> Hi everyone,
> I am very new to PHP and trying to learn the glob() function. I copied
> the example on php.net :
>
>  foreach (glob("*.txt") as $filename) {
>    echo "$filename size " . filesize($filename) . "\n";
> }
> ?>
>
> When I ran the script, I got this error message:
> Fatal error: Call to undefined function  glob() in
> /usr/local/apache2/htdocs/hrms/globtest.php on line 2
>
> I am running PHP 5.2.17 on CentOS 4.8 . How do I compile PHP to get
> the glob function in ?
> Please help.
>
>
> --
> al
>
> --
> 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



[PHP] Please help with glob

2011-04-04 Thread Al Mangkok
Hi everyone,
I am very new to PHP and trying to learn the glob() function. I copied
the example on php.net :



When I ran the script, I got this error message:
Fatal error: Call to undefined function  glob() in
/usr/local/apache2/htdocs/hrms/globtest.php on line 2

I am running PHP 5.2.17 on CentOS 4.8 . How do I compile PHP to get
the glob function in ?
Please help.


--
al

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



Re: [PHP] Last Name extraction in query

2011-04-04 Thread Andre Polykanine
Hello Geoff,

As  I  dislike forums and like mailing lists (yes, an old habbit :-)),
so here it is:
mysql-subscr...@lists.mysql.com
(that's for subscribing, indeed).
And sorry for the offtopic.

-- 
With best regards from Ukraine,
Andre
Skype: Francophile
My blog: http://oire.org/menelion (mostly in Russian)
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion

 Original message 
From: Geoff Lane 
To: php-general@lists.php.net
Date created: , 7:46:26 PM
Subject: [PHP] Last Name extraction in query


   On Monday, April 4, 2011, Jim Giner wrote:

> Actually - I can't seem to find a mysql newsgroup anywhere.  The
> ones that  come up in google search are all dead and buried.

You could try http://forums.mysql.com/ or have a look around Yahoo
groups (e.g. php_my...@yahoogroups.com).

HTH,

-- 
Geoff


-- 
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



Re: [PHP] Last Name extraction in query

2011-04-04 Thread Jim Giner
To those who have been so helpful:
I did manage to subscribe to a mysql mailing list.  thanks for the pointers.

As for my orig problem - for those who are intereseted:

The FIELD function apparently doesn't work in 5.0.2, even tho it is in the 
online ref manual.  I was given a suggestion of using INSTR and that worked 
beautifully.  Here's how it looked in my Select statement:

$q = "SELECT race_winner,count(race_date) as wins,
  SUBSTR(race_winner,INSTR(race_winner,' ')+1) as last_name
FROM `trk_races`
WHERE race_winner IS NOT NULL
GROUP BY race_winner
ORDER BY wins DESC,last_name";


It works just as I wanted it to.

Thanks to all.




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



Re: [PHP] Last Name extraction in query

2011-04-04 Thread Bastien Koert
On Mon, Apr 4, 2011 at 2:40 PM, Steve Staples  wrote:
> On Mon, 2011-04-04 at 14:06 -0400, Jim Giner wrote:
>> no - that address came back undeliverable.
>> >
>> > To subscribe to the list, send an empty message to
>> > 
>> >
>> > Marc
>>
>>
>>
> http://lists.mysql.com/mysql
>
> there is the subscribe box on the right side... use that.   they are a
> helpful bunch over there.
>
> --
>
> Steve Staples
> Web Application Developer
> MNSi (Managed Network Systems Inc.)
> 519.258.2333 x8414
> http://www.mnsi.net
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Try using LOCATE instead of the FIELD function

$q = "SELECT race_winner,count(race_date) as wins,
substr(race_winner,LOCATE(' ',race_winner)) as last_name


-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] Last Name extraction in query

2011-04-04 Thread Steve Staples
On Mon, 2011-04-04 at 14:06 -0400, Jim Giner wrote:
> no - that address came back undeliverable.
> >
> > To subscribe to the list, send an empty message to
> > 
> >
> > Marc 
> 
> 
> 
http://lists.mysql.com/mysql

there is the subscribe box on the right side... use that.   they are a
helpful bunch over there.

-- 

Steve Staples
Web Application Developer
MNSi (Managed Network Systems Inc.)
519.258.2333 x8414
http://www.mnsi.net


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



Re: [PHP] Last Name extraction in query

2011-04-04 Thread Jim Giner
no - that address came back undeliverable.
>
> To subscribe to the list, send an empty message to
> 
>
> Marc 



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



Re: [PHP] Last Name extraction in query

2011-04-04 Thread Jim Giner
Thanks - will do!
> I found a mailing list that might work for you:
>
> To subscribe to the list, send an empty message to
> 
>
> Marc 



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



Re: [PHP] Last Name extraction in query

2011-04-04 Thread sono-io
Jim,

> Actually - I can't seem to find a mysql newsgroup anywhere.  The ones that 
> come up in google search are all dead and buried. 

I found a mailing list that might work for you:

To subscribe to the list, send an empty message to
 

Marc

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



Re: [PHP] Last Name extraction in query

2011-04-04 Thread Hans Åhlin
Read about Friday posting ;)
http://news.php.net/php.general/306939

2011/4/4 Geoff Lane :
>  On Monday, April 4, 2011, Jim Giner wrote:
>
>> Actually - I can't seem to find a mysql newsgroup anywhere.  The
>> ones that  come up in google search are all dead and buried.
>
> You could try http://forums.mysql.com/ or have a look around Yahoo
> groups (e.g. php_my...@yahoogroups.com).
>
> HTH,
>
> --
> Geoff
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 


**
 Hans Åhlin
   Tel: +46761488019
   icq: 275232967
   http://www.kronan-net.com/
   irc://irc.freenode.net:6667 - TheCoin
**

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



Re: [PHP] Last Name extraction in query

2011-04-04 Thread Geoff Lane
 On Monday, April 4, 2011, Jim Giner wrote:

> Actually - I can't seem to find a mysql newsgroup anywhere.  The
> ones that  come up in google search are all dead and buried.

You could try http://forums.mysql.com/ or have a look around Yahoo
groups (e.g. php_my...@yahoogroups.com).

HTH,

-- 
Geoff


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



Re: [PHP] Last Name extraction in query

2011-04-04 Thread Robert Stone
Hi Jim,

I think that you'll find that ' ' is treated as a NULL and as such will always 
return zero.
You are no catering for multiple spaces in the column race_winner.
If you were using Oracle, their INSTR function has an optional argument that 
allows you to search backwards from the end of a string, but you're not, so my 
guess is that you'll have to extract the results into an array, manipulate the 
race_winner column, sort the array, then do whatever is coming next.
I'm not a MySql expert, just putting in my two bob's worth.
Don't forget to LTRIM(RTRIM(race_winner)).

Cheers,




--- Em seg, 4/4/11, Jim Giner  escreveu:

De: Jim Giner 
Assunto: [PHP] Last Name extraction in query
Para: php-general@lists.php.net
Data: Segunda-feira, 4 de Abril de 2011, 12:50

having a problem posting this message - forgive any duplication please.

Hi,
I'm trying to use sql to extract the last name from a person's name field in
my table.  Here's my Select:

$q = "SELECT race_winner,count(race_date) as wins,
substr(race_winner,FIELD(' ',race_winner)) as last_name

etc.,,,



My result keeps coming up with a 0 for the FIELD portion I assume
since my output shows a blank last_name.  From the docs I believe it should 
be giving me the right-most portion of the 'race_winner' field beginning 
where the first space char is found.

Am I not using this correctly?  Is there a better way to do this?  I'm
trying to have my results sorted by last name and since the table was not
built with separate first/last name fields, I'm stuck with figuring
somethign out.





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




  

Re: [PHP] Last Name extraction in query

2011-04-04 Thread Jim Giner
Actually - I can't seem to find a mysql newsgroup anywhere.  The ones that 
come up in google search are all dead and buried. 



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



Re: [PHP] Last Name extraction in query

2011-04-04 Thread Jim Giner
good point.  So wrapped up in making my php script work that I didn't think 
about that.
"Ashley Sheridan"  wrote in message 
news:1301936583.2288.3.camel@localhost...
> On Mon, 2011-04-04 at 11:50 -0400, Jim Giner wrote:
>
>> having a problem posting this message - forgive any duplication please.
>>
>> Hi,
>> I'm trying to use sql to extract the last name from a person's name field 
>> in
>> my table.  Here's my Select:
>>
>> $q = "SELECT race_winner,count(race_date) as wins,
>> substr(race_winner,FIELD(' ',race_winner)) as last_name
>>
>> etc.,,,
>>
>>
>>
>> My result keeps coming up with a 0 for the FIELD portion I assume
>> since my output shows a blank last_name.  From the docs I believe it 
>> should
>> be giving me the right-most portion of the 'race_winner' field beginning
>> where the first space char is found.
>>
>> Am I not using this correctly?  Is there a better way to do this?  I'm
>> trying to have my results sorted by last name and since the table was not
>> built with separate first/last name fields, I'm stuck with figuring
>> somethign out.
>>
>>
>>
>>
>>
>
>
> Where's the PHP question in this, as what you've asked would be better
> asked on a database list, as it's an SQL query.
>
> 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] Last Name extraction in query

2011-04-04 Thread Ashley Sheridan
On Mon, 2011-04-04 at 11:50 -0400, Jim Giner wrote:

> having a problem posting this message - forgive any duplication please.
> 
> Hi,
> I'm trying to use sql to extract the last name from a person's name field in
> my table.  Here's my Select:
> 
> $q = "SELECT race_winner,count(race_date) as wins,
> substr(race_winner,FIELD(' ',race_winner)) as last_name
> 
> etc.,,,
> 
> 
> 
> My result keeps coming up with a 0 for the FIELD portion I assume
> since my output shows a blank last_name.  From the docs I believe it should 
> be giving me the right-most portion of the 'race_winner' field beginning 
> where the first space char is found.
> 
> Am I not using this correctly?  Is there a better way to do this?  I'm
> trying to have my results sorted by last name and since the table was not
> built with separate first/last name fields, I'm stuck with figuring
> somethign out.
> 
> 
> 
> 
> 


Where's the PHP question in this, as what you've asked would be better
asked on a database list, as it's an SQL query.

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




Re: [PHP] DateTime using DateTimeZone Timestamp problem

2011-04-04 Thread Ashley Sheridan
On Mon, 2011-04-04 at 16:35 +0100, Ian wrote:

> Hi,
> 
> I have a problem using the php built in classes DateTime and DateTimeZone.
> 
> The idea behind the following code is to return the timestamp for the
> current time in Singapore (or other places).  What it actually returns
> is the timestamp for the local system. Other formatted dates appear to
> return correctly, which is why I am puzzled.
> 
> I am using the latest php 5.3.6 compiled from source on a OpenVZ CentOS
> container. All packages are up to date.
> 
> Am I doing something wrong or is this a bug?
> 
> I can workaround this problem my parsing the correctly formatted date
> using strtotime() but I would like to know what's going on.
> 
> 
> 
> This is the output of the script:
> 
>   Current time in Asia/Singapore is 2011-04-04 23:32:36
>   Timestamp for Asia/Singapore is 1301931156
>   Date created from previous timestamp is 2011-04-04 16:32:36
> 
> The code is :
> 
>  
> $timezone="Asia/Singapore";
> 
> # Create Timezone object
> $remote_timezone  = new DateTimeZone($timezone);
> 
> # Create datetime object
> $remote_time  = new DateTime("now" , $remote_timezone);
> 
> # Print the date
> print "Current time in {$timezone} ";
> print "is {$remote_time->format("Y-m-d H:i:s")}";
> 
> # Print the timestamp
> print "Timestamp for {$timezone} ";
> print "is {$remote_time->format("U")}";
> 
> # Get the timestamp and create a date from it
> $timestamp = (int)$remote_time->format("U");
> 
> # Show the formatted date created from timestamp
> print "Date created from previous timestamp is ";
> print date("Y-m-d H:i:s",$timestamp)."";
> 
> ?>
> 
> 
> 


What do you mean it only returns the timestamp for the local system? Did
you want PHP to know what time the visitors are on? PHP won't know about
that, all you can do is set the timezone for the script based on some
information you're receiving from a clients machine, otherwise PHP won't
know, because it's only run on the server and doesn't know about the
client machines? Is this what you're trying to do, or did I
misunderstand?

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




[PHP] Last Name extraction in query

2011-04-04 Thread Jim Giner
having a problem posting this message - forgive any duplication please.

Hi,
I'm trying to use sql to extract the last name from a person's name field in
my table.  Here's my Select:

$q = "SELECT race_winner,count(race_date) as wins,
substr(race_winner,FIELD(' ',race_winner)) as last_name

etc.,,,



My result keeps coming up with a 0 for the FIELD portion I assume
since my output shows a blank last_name.  From the docs I believe it should 
be giving me the right-most portion of the 'race_winner' field beginning 
where the first space char is found.

Am I not using this correctly?  Is there a better way to do this?  I'm
trying to have my results sorted by last name and since the table was not
built with separate first/last name fields, I'm stuck with figuring
somethign out.





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



[PHP] DateTime using DateTimeZone Timestamp problem

2011-04-04 Thread Ian
Hi,

I have a problem using the php built in classes DateTime and DateTimeZone.

The idea behind the following code is to return the timestamp for the
current time in Singapore (or other places).  What it actually returns
is the timestamp for the local system. Other formatted dates appear to
return correctly, which is why I am puzzled.

I am using the latest php 5.3.6 compiled from source on a OpenVZ CentOS
container. All packages are up to date.

Am I doing something wrong or is this a bug?

I can workaround this problem my parsing the correctly formatted date
using strtotime() but I would like to know what's going on.



This is the output of the script:

Current time in Asia/Singapore is 2011-04-04 23:32:36
Timestamp for Asia/Singapore is 1301931156
Date created from previous timestamp is 2011-04-04 16:32:36

The code is :

format("Y-m-d H:i:s")}";

# Print the timestamp
print "Timestamp for {$timezone} ";
print "is {$remote_time->format("U")}";

# Get the timestamp and create a date from it
$timestamp = (int)$remote_time->format("U");

# Show the formatted date created from timestamp
print "Date created from previous timestamp is ";
print date("Y-m-d H:i:s",$timestamp)."";

?>



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



Re: [PHP] File locking with PHP functions

2011-04-04 Thread Louis Huppenbauer
It may not be a direct answer to your question, but...
You could just use flock() to lock the file while accessing it.

louis

2011/4/4 Paul M Foster :
> I'd like to know (from someone who knows the internals more than I do)
> whether the following functions lock files and to what extent:
>
> fopen($filename, 'w');
>
> Does this function lock the file from writes until fclose()?
> Does it lock from reads as well?
>
> fopen($filename, 'r+');
>
> Does this function lock the file from writes until fclose()?
> Does it lock the file from reads as well?
>
> file($filename);
>
> Does this function lock the file from writes until finished?
> Does it lock the file from reads as well?
>
> All this is in the context of a Linux/Unix web server.
>
> Paul
>
> --
> Paul M. Foster
> http://noferblatz.com
> http://quillandmouse.com
>
> --
> 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



Re: [PHP] File locking with PHP functions

2011-04-04 Thread Stuart Dallas
On Monday, 4 April 2011 at 15:28, Paul M Foster wrote:
I'd like to know (from someone who knows the internals more than I do)
> whether the following functions lock files and to what extent:
> 
> fopen($filename, 'w');
> 
> Does this function lock the file from writes until fclose()?
> Does it lock from reads as well?
> 
> fopen($filename, 'r+');
> 
> Does this function lock the file from writes until fclose()?
> Does it lock the file from reads as well?
> 
> file($filename);
> 
> Does this function lock the file from writes until finished?
> Does it lock the file from reads as well?
> 
> All this is in the context of a Linux/Unix web server.

No, fopen does not lock the file. Check out http://php.net/flock but be sure to 
read all of that page because there are some gotchas with using it.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/





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



[PHP] File locking with PHP functions

2011-04-04 Thread Paul M Foster
I'd like to know (from someone who knows the internals more than I do)
whether the following functions lock files and to what extent:

fopen($filename, 'w');

Does this function lock the file from writes until fclose()?
Does it lock from reads as well?

fopen($filename, 'r+');

Does this function lock the file from writes until fclose()?
Does it lock the file from reads as well?

file($filename);

Does this function lock the file from writes until finished?
Does it lock the file from reads as well?

All this is in the context of a Linux/Unix web server.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



RE: [PHP] newbie - function is undefined

2011-04-04 Thread Jay Blanchard
[snip]
Oh no no no. You can use PHP to GENERATE JS, CSS, HTML, XML, etc. You
just can't CALL JS from PHP and get a response.[/snip]

Fair enough, I just wanted to make sure that we were all on the same
page because some of the answers given to the OP may have been somewhat
confusing. Many of you know how much I have tried to make sure that
posters in the past have understood the difference between client-side
vs. server-side. AJAX blurs that line for some developers but I still
believe that line to be steadfastly in place.



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



Re: [PHP] newbie - function is undefined

2011-04-04 Thread Paul M Foster
On Mon, Apr 04, 2011 at 08:03:46AM -0500, Jay Blanchard wrote:

> [snip]
> Short answer : yes.
> Medium answer : probably, but really yes.
> Long answer : unless you are providing some sort of mechanism to hold
> the current state of PHP, eject the required JS code to get a value
> from the client and return it to the server which then recreates the
> working environment and carries on execution (try debugging THAT),
> then almost certainly.
> [/snip]
> 
> So dynamically generated pages by PHP shouldn't spit out any JS of any
> type?

Spit out all the Javascript you want with dynamically generated PHP
pages. Just don't try to call a Javascript function from PHP. That was
the OP's mistake.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] newbie - function is undefined

2011-04-04 Thread Richard Quadling
On 4 April 2011 14:03, Jay Blanchard  wrote:
> [snip]
> Short answer : yes.
> Medium answer : probably, but really yes.
> Long answer : unless you are providing some sort of mechanism to hold
> the current state of PHP, eject the required JS code to get a value
> from the client and return it to the server which then recreates the
> working environment and carries on execution (try debugging THAT),
> then almost certainly.
> [/snip]
>
> So dynamically generated pages by PHP shouldn't spit out any JS of any
> type?
>

Oh no no no. You can use PHP to GENERATE JS, CSS, HTML, XML, etc. You
just can't CALL JS from PHP and get a response.

I use PHP to create JS code a LOT. The CSS/JS Combinator uses PHP to
shrink and cache the JS and CSS code to reduce the number of hits a
page generates.



-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



RE: [PHP] newbie - function is undefined

2011-04-04 Thread Ashley Sheridan
On Mon, 2011-04-04 at 08:03 -0500, Jay Blanchard wrote:

> [snip]
> Short answer : yes.
> Medium answer : probably, but really yes.
> Long answer : unless you are providing some sort of mechanism to hold
> the current state of PHP, eject the required JS code to get a value
> from the client and return it to the server which then recreates the
> working environment and carries on execution (try debugging THAT),
> then almost certainly.
> [/snip]
> 
> So dynamically generated pages by PHP shouldn't spit out any JS of any
> type?
> 


That's not what he said. PHP can more than adequately output Javascript
(or any other kind of output you can think of really, such as XML, PDF,
images, etc), it's just generally most people use it to output HTML.
Quite often it's easiest when passing data from PHP to Javascript to do
it by outputting Javascript code directly, but it does help to separate
PHP from the client-side. So rather than think of embedding PHP in an
HTML file, it's really the other way around, because as soon as you take
an HTML file and include PHP, the whole thing is parsed by php the
program on the server, which then outputs HTML to Apache, rather than
Apache just grabbing the plain HTML and sending it to the client.

Because web servers (typically) don't parse Javascript code, PHP knows
nothing about the functions you've declared in it, even if PHP was
responsible for outputting the Javascript code itself, in much the same
way that you wouldn't expect PHP to output CSS and know whether your
browser has correcly applied the styles or not. Everything that happens
on the client-side is outside of PHP and the server.

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




[PHP] Re: XML... Useful or another layer of complexity?

2011-04-04 Thread Pete Ford

On 03/04/11 19:41, Jason Pruim wrote:

So the subject says it all... And yes I know this isn't related to PHP but it's 
the weekend and I trust the opinions on this list more then any other list I 
have seen. I've been doing alot of reading on XML and honestly it looks pretty 
cool... BUT the question is... Is it truly useful or is it just another layer 
that we have to write?

 From what I can tell it looks like it could stabilize some of my programming 
in regards to databases, and possibly if I have to move information from one 
application to another.

But is it worth the added coding or should I just interact with the pieces 
directly?

Thoughts? Questions? Flames? :)




Yes :)

--
Peter Ford, Developer phone: 01580 89 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

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



RE: [PHP] newbie - function is undefined

2011-04-04 Thread Jay Blanchard
[snip]
Short answer : yes.
Medium answer : probably, but really yes.
Long answer : unless you are providing some sort of mechanism to hold
the current state of PHP, eject the required JS code to get a value
from the client and return it to the server which then recreates the
working environment and carries on execution (try debugging THAT),
then almost certainly.
[/snip]

So dynamically generated pages by PHP shouldn't spit out any JS of any
type?

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



[PHP] SoapClient and apache strong authentication with openssl certificate

2011-04-04 Thread Denis Fingonnet
Hello all,

I have a question for you.
I succeeded on generating certificates, securing apache and connecting to a
web service using soap with a certificate authentication mecanism.

Now, i'm wondering what the openssl module can do.

My wish is to generate a client certificate through the openssl module's
functions.
But the documentation isn't very useful at the moment.

I'm trying to do the exact same thing as :
https://gist.github.com/901407starting at the line 8
It looks like :
$privkey = openssl_pkey_new();
$privkey = openssl_pkey_new();
$csr = openssl_csr_new($dn, $privkey);
$sscert = openssl_csr_sign($csr, file_get_contents('/PATH_TO/ca.crt'),
file_get_contents('/PATH_TO/ca.key'), 1);
openssl_x509_export($sscert, $cert);
openssl_pkcs12_export($cert, $pkcs12, $privkey, '', array('clcerts',
'nokeys'));

And here I'm stuck. Is there a way to do the following command in PHP ?
openssl pkcs12 -nodes -clcerts -in cacert.p12 -out client.pem

thanks

Denis Fingonnet


Re: [PHP] newbie - function is undefined

2011-04-04 Thread Richard Quadling
On 4 April 2011 12:12, Jay Blanchard  wrote:
> So all of the pages I generate with PHP that call JavaScript functions
> and libraries are doing it wrong?

Short answer : yes.
Medium answer : probably, but really yes.
Long answer : unless you are providing some sort of mechanism to hold
the current state of PHP, eject the required JS code to get a value
from the client and return it to the server which then recreates the
working environment and carries on execution (try debugging THAT),
then almost certainly.

Under normal circumstances, the PHP code is completely finished
running before anything gets to the client. There is no mechanism for
allowing _this_ script to get a response to a JS call whilst running.

It is like the game of "pass the parcel". Your job (as in the PHP
script) is to unwrap 1 layer of paper and pass it on. That's it. PHP
runs and builds the appropriate output in response to the request that
the server directed to the PHP handler. Once the output has been
passed to the server, the PHP script is finished.

Whilst building the output, PHP cannot talk to the client. At the most
fundamental level, the client (the browser) is not listening for
anyone other than a response to the request it made to the server.





-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



RE: [PHP] newbie - function is undefined

2011-04-04 Thread Jay Blanchard
[snip]
JavaScript is a browser-side language, browsers have cache, cache sticks
around, meaning that you can tell the browser to cache the JS file and
not
download it from the server (every time) if its being included on the
browser end (which js is). All means faster page load times post initial
load, and less bandwidth. If you include the JS file with php, every
time
you request the page the javascript will be pulled from your hard drive
by
php and sent back as a part of the server response (your end web page).
[/snip]

So all of the pages I generate with PHP that call JavaScript functions
and libraries are doing it wrong?

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



Re: [PHP] Re: Config files: what is best? (was: Re: [PHP] XML... Useful or another layer of complexity?)

2011-04-04 Thread Richard Quadling
On 3 April 2011 21:38, Peter Lind  wrote:
> On 3 April 2011 22:35, Andre Polykanine  wrote:
>> Hello Peter,
>>
>> Thanks a lot! And is there a way to set (write) custom values in files
>> other than php.ini? Sorry, didn't find such a function.
>>
>
> I haven't come across any, but then again, I haven't had the need so
> never looked much ... It would be rather easy to generate though
>
> Regards
> Peter
>
> --
> 
> WWW: plphp.dk / plind.dk
> LinkedIn: plind
> BeWelcome/Couchsurfing: Fake51
> Twitter: kafe15
> 
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

For a truly quick and dirty config, then just use PHP.

A similar mechanism is used by PhD - the PHP Documentation building tool.

 'value1');

// Load the saved config.
$loadedConfig = include './config.inc';

// Merge configs.
$config = array_merge($config, $loadedConfig);

// Manipulate config.
$config['item1'] = 'value2';

// Save config.
file_put_contents('./config.inc', '



-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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