Re: [PHP] Apply the hyper link ( javascript functon ) with php

2006-10-11 Thread Andrei

Make sure your $dir variable isn't containing the path to your file from
your OS file system. This should be an apache (or whatever) path (an URL).

Andy


[EMAIL PROTECTED] wrote:
 Richard Lynch wrote:
 
 On Sun, October 8, 2006 6:53 pm, [EMAIL PROTECTED] wrote:
  

 How to apply the following function with php ?
 a href=javascript:popup('index.htm') Test /a


 If you're new to PHP, be a minimalist, and pull out PHP only when you
 absolutely have to:

 a href=javascript:popup('?php echo $dir?/index.htm') Test /a

 Since $dir is the ONLY part you want to be changing, use PHP only for
 that part.

 Switching in/out of PHP like this is very fast/cheap, and leaves you
 with HTML that mostly looks just like you are used to.

 YMMV

  

 Hello to you,
 
 php web page ( test.php ) :
 
 script language=javascript type=text/javascript
 !--
 function popup(page)
 {
 window.open(page,title, height=100,width=100);
 }
 // --
 /script
 
 a href=javascript:popup('./?php echo $dir?/index.htm') Test /a
 
 Result : homepage error
 
 Web Server error log :
 
 [Tue Oct 10 18:07:36 2006] [error] [client 202.108.22.70] File does not
 exist: /home/web/index.htm
 [Tue Oct 10 18:10:12 2006] [error] [client 61.135.145.217] File does not
 exist: /home/web/test2004.htm
 [Tue Oct 10 18:10:14 2006] [error] [client 61.135.145.217] File does not
 exist: /home/web/readme.htm
 
 Please help, thanks !
 
 Edward.
 

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



Re: [PHP] ftp_put and ftp_chmod does not work

2006-10-11 Thread Chris


When safe mode is enabled, PHP checks whether the files or directories you 
are about to operate on have the same UID (owner) as the script that is 
being executed. In addition, you cannot set the SUID, SGID and sticky 
bits.


It means that the UID (owner) of the folder ought to be the apache user or 
the ftp user?


Whoever owns the php script (which would be the ftp user).

They need to match exactly (same user, same group).

You can relax safe-mode to check the same groups 
(http://www.php.net/manual/en/features.safe-mode.php#ini.safe-mode-gid) 
rather than the same user  group but that's up to the server admin / host.


move_uploaded_file will always fail because the file isn't uploaded 
through a form. The documentation makes this rather clear (see also 
is_uploaded_file).


The file realy was uploaded by a form and it is in the temporary upload 
folder of php.


I misunderstood then.


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] need help to build a query

2006-10-11 Thread Ivo F.A.C. Fokkema
On Tue, 10 Oct 2006 14:22:54 -0500, Richard Lynch wrote:
 On Mon, October 9, 2006 2:58 pm, John Wells wrote:
 On 10/9/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 but I know there must be much better solution then this one.

 You're right: Simply JOIN your queries...

 SELECT order_id, order_date, order_status, file_name
 FROM orders
 JOIN uploaded_files AS uf ON orders.order_id = uf.order_id
 ORDER BY orders.order_id DESC
 LIMIT 100
 
 This will miss all the orders with no upload at all, unlike the
 original.

As specified elsewhere in this thread, use outer join to prevent losing
orders with no uploads.

 AND it limits you to the 100 uploaded files, not 100 orders.
 
 This is a lot more subtle problem than it seems at first glance, eh?

To fetch all uploaded filenames in one result row, and solving the limit
problem all at once, see group_concat(). Mind you, works only with MySQL
4.1...

Ivo

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



Re: [PHP] foreach

2006-10-11 Thread Ivo F.A.C. Fokkema
On Tue, 10 Oct 2006 14:34:54 -0400, John Nichel wrote:

 Chris Boget wrote:
 $last = end ( $numbers );
 reset ( $numbers );
 
 I thought foreach() already performed a reset()?  Why do it again here?
 
 
 Well, corn my fritters, according to TFM, it does this indeed.  Maybe an 
 old dog can learn new tricks.  ;)

Actually, foreach() creates a copy of the mentioned array, and the array
pointer of the original array is not modified. Very useful to know if you
append entries to the array you're foreach()-ing and pulling your hair out
why foreach() doesn't iterate through those new entries...

An way of going through the array independent of the actual values (since
using end() relies on unique values):

$n = count($numbers);
$i = 0;
foreach ($numbers as $number) {
$i ++;
if ($i == $n) {
// Last element...
} else {
// Not the last element...
}
}

Ivo

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



Re: [PHP] ereg_replace with user defined function?

2006-10-11 Thread Frank Arensmeier


10 okt 2006 kl. 19.25 skrev Roman Neuhauser:


# [EMAIL PROTECTED] / 2006-10-09 22:01:34 +0200:

Thank you Ilaria and Roman for your input. I did not know that preg
is able to deal with PCRE patterns.


preg is obviously short for Perl REGular expressions, while
PCRE positively means Perl-Compatible Regular Expressions.
The regexp syntax from Perl is a superset of POSIX extended
regexps, so anything ereg_ function accept will be good for
preg_ as well (but beware of pattern delimiters).


Thanks for the info. I didn't know that.




As a matter of fact I came up
with the following solution (if someone is interested):


What problem does it solve? I mean, why are you trying to avoid
preg_replace_callback() in the first place?



Maybe because I didn't know better? Initially, I was using  
ereg_replace for replacing metric numbers with imperial ones. But  
obviously, ereg_replace replaces all instances in the given text  
string. A text containing more than one instance of the same unit,  
was replaced by the calculated replacement string of the first  
finding. So I had to think about other ways to do this - which  
brought me to preg_replace_callback (as I already said - I didn't  
know that preg takes POSIX patterns as well).


Would you suggest a different way? Would it be faster to do the  
replacement with preg_replace_callback compared to the function I wrote?


A page like this one: http://www.nikehydraulics.com/products/ 
product_chooser_gb.php?productMaingroup=5productSubgroup=33


.. gets converted within 0.32 / 0.34 seconds which I think is quite ok.

/frank



the function takes a text and an array with converters like:

$converters[] = array ( metric = mm, imperial = in,
ratio  = 0.039370079, round = 1 );
$converters[] = array ( metric = m, imperial = ft, ratio
= 3.280839895, round = 1 );


function convertTextString ( $text, $convertTable )
{
# this function takes a text string, searches for numbers to
convert, convert those numbers and returns
# the complete text again.

if ( !ereg ( [[:digit:]], $text ) ) // if the text does not
contain any numbers, return the text as it is
{
return $text;
}

foreach ( $convertTable as $convertKey = $convertUnit )
{
$pattern =
		((\d{1,10}[,|.]*\d{0,10})*(\s)(%s)([$|\s|.|,|\)|/]+| $)); //  
this regex
looks for a number followed by white space,  followed by the  
metric unit,

followed by a closing character like  ., , or )
$pattern = sprintf ( $pattern, $convertUnit['metric'] );

while ( preg_match ( $pattern, $text, $matches ) )
{
$matches[1] = str_replace ( ,, ., $matches[1] );
			// in case  numbers are written like 6,6 m, we need to  
replace , with

.
// because we do not want to return 0, we have to
make shure that  the new value is not zero.
$itterator = 0;
do {
$value = round ( ( $matches[1] *
$convertUnit['ratio'] ),  $convertUnit['round'] 
+ $itterator  );
++$itterator;
} while ( $value == 0 || $itterator == 10 );

$replacement = $value . $2 .
$convertUnit['imperial'] . $4;
$text = preg_replace ( $pattern, $replacement,
$text, 1 );
}
}
return $text;
}


--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991



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



Re: [PHP] Re: moving to other web server

2006-10-11 Thread David Robley
Chris wrote:

 David Robley wrote:
 Afan Pasalic wrote:
 
 hi to all,
 we are moving our web server from one to other hosting company. we have
 chance to request what version of php i want to be installed, 4 or 5.
 Current web server works on php 4.3.4 we don't use any classes,
 functions only. as far as I know, in our case moving from 4 to 5
 shouldn't be any problem, no concerns. but, anyway, where can I expect
 errors - except in oop?

 thanks for any help.

 -afan
 
 If you currently use a variable named $this you can expect problems.
 
 Care to elaborate? I use that all the time on both php4  php5 servers
 and it works fine.
 

When I upgraded my service to php5 a couple of scripts that used $this as a
variable name, as opposed to $this-value, were spitting errors - I don't
remember the actual error but let me see if I can reproduce it;

?php
$this = '';
echo $this;
?

Fatal error: Cannot re-assign $this
in /usr/local/apache2/htdocs/test/file.php on line 2



Cheers
-- 
David Robley

I love the novels of D. H. Lawrence, said the lady chattily.
Today is Prickle-Prickle, the 65th day of Bureaucracy in the YOLD 3172. 

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



Re: [PHP] Re: moving to other web server

2006-10-11 Thread Chris

David Robley wrote:

Chris wrote:


David Robley wrote:

Afan Pasalic wrote:


hi to all,
we are moving our web server from one to other hosting company. we have
chance to request what version of php i want to be installed, 4 or 5.
Current web server works on php 4.3.4 we don't use any classes,
functions only. as far as I know, in our case moving from 4 to 5
shouldn't be any problem, no concerns. but, anyway, where can I expect
errors - except in oop?

thanks for any help.

-afan

If you currently use a variable named $this you can expect problems.

Care to elaborate? I use that all the time on both php4  php5 servers
and it works fine.



When I upgraded my service to php5 a couple of scripts that used $this as a
variable name, as opposed to $this-value, were spitting errors - I don't
remember the actual error but let me see if I can reproduce it;

?php
$this = '';
echo $this;
?

Fatal error: Cannot re-assign $this
in /usr/local/apache2/htdocs/test/file.php on line 2


Ahhh... I don't use it outside of a class situation so I guess that's 
why I haven't run into it before :)


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] ereg_replace with user defined function?

2006-10-11 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-10-11 09:52:51 +0200:
 
 10 okt 2006 kl. 19.25 skrev Roman Neuhauser:
 
 # [EMAIL PROTECTED] / 2006-10-09 22:01:34 +0200:
 Thank you Ilaria and Roman for your input. I did not know that preg
 is able to deal with PCRE patterns.
 
 preg is obviously short for Perl REGular expressions, while
 PCRE positively means Perl-Compatible Regular Expressions.
 The regexp syntax from Perl is a superset of POSIX extended
 regexps, so anything ereg_ function accept will be good for
 preg_ as well (but beware of pattern delimiters).
 
 Thanks for the info. I didn't know that.

NP, glad to be of help. The relationship is quite obvious if you
look at both syntaxes.

 As a matter of fact I came up
 with the following solution (if someone is interested):
 
 What problem does it solve? I mean, why are you trying to avoid
 preg_replace_callback() in the first place?
 
 
 Maybe because I didn't know better?

Well your question mentioned preg_replace_callback() so I thought
maybe there was something about the function you didn't like.

 Initially, I was using  ereg_replace for replacing metric numbers with
 imperial ones. But  obviously, ereg_replace replaces all instances in
 the given text  string. A text containing more than one instance of
 the same unit,  was replaced by the calculated replacement string of
 the first  finding. So I had to think about other ways to do this -
 which  brought me to preg_replace_callback (as I already said - I
 didn't  know that preg takes POSIX patterns as well).
 
 Would you suggest a different way? Would it be faster to do the  
 replacement with preg_replace_callback compared to the function I wrote?

Definitely, and probably by several orders of magnitude.

 A page like this one: http://www.nikehydraulics.com/products/ 
 product_chooser_gb.php?productMaingroup=5productSubgroup=33
 
 .. gets converted within 0.32 / 0.34 seconds which I think is quite ok.

If the time covers only the conversion then it's quite terrible.

Looking at the convertTextString() function below there's a few
obvious optimizations waiting to be done, and... turning the foreach
into a single preg_replace_callback() is the one that begs
implementing the most (the code below's been tested and works):

class convertor
{
const SI_to_Imperial = 0;
const Imperial_to_SI = 1;

function convert($amount, $unit, $direction)
{
return sprintf(
whatever '%s' of '%s' is in the Imperial system
  , $amount
  , $unit
);
}
}
function callbackSI2IS(array $SIspec)
{
return convertor::convert(
$SIspec[1]
  , $SIspec[2]
  , convertor::SI_to_Imperial
);
}

$p = '~
((?:\d+[,|.])*\d+) # amount
\s*
(m{1,2}\b) # meters or millis
 ~x';
echo preg_replace_callback(
$p
  , 'callbackSI2IS'
  , file_get_contents('php://stdin')
);


 the function takes a text and an array with converters like:
 
 $converters[] = array ( metric = mm, imperial = in,
 ratio  = 0.039370079, round = 1 );
 $converters[] = array ( metric = m, imperial = ft, ratio
 = 3.280839895, round = 1 );
 
 
 function convertTextString ( $text, $convertTable )
 {
 # this function takes a text string, searches for numbers to
 convert, convert those numbers and returns
 # the complete text again.
 
 if ( !ereg ( [[:digit:]], $text ) ) // if the text does not
 contain any numbers, return the text as it is
 {
 return $text;
 }
 
 foreach ( $convertTable as $convertKey = $convertUnit )
 {
 $pattern =
 ((\d{1,10}[,|.]*\d{0,10})*(\s)(%s)([$|\s|.|,|\)|/]+| $)); 
 //  this regex
 looks for a number followed by white space,  followed by the  
 metric unit,
 followed by a closing character like  ., , or )
 $pattern = sprintf ( $pattern, $convertUnit['metric'] );
 
 while ( preg_match ( $pattern, $text, $matches ) )
 {
 $matches[1] = str_replace ( ,, ., $matches[1] );
 // in case  numbers are written like 6,6 m, we 
 need to  replace , with
 .
 // because we do not want to return 0, we have to
 make shure that  the new value is not zero.
 $itterator = 0;
 do {
 $value = round ( ( $matches[1] *
 $convertUnit['ratio'] ),  
 $convertUnit['round'] + $itterator  );
 ++$itterator;
 } while ( $value == 0 || $itterator == 10 );
 
 $replacement = $value . $2 .
 $convertUnit['imperial'] . $4;
 

Re: [PHP] Seperate HTML from PHP

2006-10-11 Thread Glenn Richmond
Yes - separation of HTML and PHP code is not really a question of speed
or efficiency.

It's about coding style. Combining the two together might be fine for
small projects, but when that project grows and grows, the readability
of your code deteriorates if you don't separate the languages, not to
mention code in a well defined style.

Glenn.

Chris wrote:
 Sancar Saran wrote:
 Hi there, following words are my ideas about that HTML PHP parting. I
 hope you can understand my broken english and do not take personally.

 SEPERATING html FROM php ARE USELESS

 Try customising a CMS (any open source) with html embedded in the php...

 Good luck and get back to us (in a few years) when you have it completed.


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



[PHP] RE: Seperate HTML from PHP

2006-10-11 Thread Jürgen Wind

brilliant!
-- 
View this message in context: 
http://www.nabble.com/Seperate-HTML-from-PHP-tf2415209.html#a6753706
Sent from the PHP - General mailing list archive at Nabble.com.

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-11 Thread Chris de Vidal
--- Johan Martin [EMAIL PROTECTED] wrote:
 You should look into getting Professional PHP5 by Lecky-Thompson,  
 Eide-Goodman, Nowicki and Cove from WROX.
...
 The collection class in chapter 5 discusses a programming problem  
 just like yours.

I will look into that, thank you.

CD

Think you#39;re a good person?  Yeah, right!  ;-)
Prove it and get ten thousand dollars:
TenThousandDollarOffer.com

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-11 Thread Chris de Vidal
--- Larry Garfield [EMAIL PROTECTED] wrote:
 For your rudimentary example of object-relational mapping below, yes, 
 performance is going to be atrocious.  That's because you're not taking any 
 advantage of the features that using OOP gives you.

Well, I /thought/ I was taking advantage of black box-style hiding (not sure 
what it's called),
that is, making sure the only place I type (and modify) my SQL query is hidden 
inside the private
method of a class.


 Again, pull extra data if you can.  A somewhat larger result set is (usually) 
 better than multiple queries.  How much you want to front-load in your object 
 and how much you want to defer to later depends on your specific problem and 
 how frequently the data will be used.

OK that somewhat answers the question.


 5) If you need to grab 100 objects at once, but just need basic data out of 
 them, use a factory.  Vis, 

(code snipped)

I /think/ I understand the code.  But I'd need more than just basic data, so I 
probably will just
write a query.


 6) If you need to do a complex query with a couple of joins and such, then 
 don't waste your time or the computer's trying to shoe-horn it into SQL.  SQL 
 is not inherently OO to start with!  Just write your query and loop it and be 
 happy.  OOP is not the answer to all problems.  Sometimes it does just make 
 matters worse, no matter what Sun tries to tell you. :-)

LOL

Yeah, I was thinking of shoe-horning things into SQL for speed.


   I want my data to _only_ be accessed from the black box called an OOP
   class. 
 
 That will work and is achievable in about 30% of all situations.  For the 
 other 70%, you will have to just hunker down and *gasp* write SQL specific to 
 the task at hand at least some of the time.  How much of the time once again 
 depends on your situation and the problem you're trying to solve.

*gasp*

:-)


From what it seems like people are telling me, it's a good idea to boot OOP 
for large numbers of
objects where I need more than just a little information and just use an SQL 
query, as I
suspected.  At least, for PHP; I wonder what Java people do in this situation.

CD

Think you#39;re a good person?  Yeah, right!  ;-)
Prove it and get ten thousand dollars:
TenThousandDollarOffer.com

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-11 Thread Satyam


- Original Message - 
From: Chris de Vidal [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Wednesday, October 11, 2006 12:42 PM
Subject: Re: [PHP] OOP slow -- am I an idiot?



--- Johan Martin [EMAIL PROTECTED] wrote:

You should look into getting Professional PHP5 by Lecky-Thompson,
Eide-Goodman, Nowicki and Cove from WROX.

...

The collection class in chapter 5 discusses a programming problem
just like yours.


I will look into that, thank you.

CD



Regardless of whether you find the sugested book or not, do take note that a 
good place for functions as the one you require, as Johan sugestests, isin a 
class representing collections of the individual objects.  Thus, it is 
usually good to have a class representing individual objects (customer) and 
collections of the same (customers) or methods that provide information on 
groups or agregates of individual items.


Satyam

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



Re: [PHP] foreach

2006-10-11 Thread Jo�o C�ndido de Souza Neto
Thanks for your tip, but unfortunately it wouldn´t help me.


Richard Lynch [EMAIL PROTECTED] escreveu na mensagem 
news:[EMAIL PROTECTED]
 On Tue, October 10, 2006 1:14 pm, João Cândido de Souza Neto wrote:
 $numbers=array(1,2,3,4,5);
 foreach ($numbers as number) {
 ...
 }

 Inside foreach, could i know if i am in the last element of the array
 $numbers?

 In general, you can't.

 If the elements are unique, you could do:

 $last = end($numbers);
   ...
   if ($last == $number) this is the end;

 Most people who want this feature are trying to suppress outputting
 a comma or other separator after the last item because they have not
 yet figured out how to use this function:
 http://php.net/implode

 -- 
 Some people have a gift link here.
 Know what I want?
 I want you to buy a CD from some starving artist.
 http://cdbaby.com/browse/from/lynch
 Yeah, I get a buck. So? 

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



Re: [PHP] ereg_replace with user defined function?

2006-10-11 Thread Frank Arensmeier

Thanks again for your suggestions.

Actually, - believe it or not - I have never written a class (I am  
still learning PHP after three years working with that language). So  
I am not quite sure of the benefits of your class. One thing I do  
realise is the benefit of replacing the foreach loop with a single  
preg_replace_callbak. Let me try to sum up:


With a preg_replace_callback I am able to look for a pattern like: a  
number ( float or integer ) followed by whitespace followed by one,  
two, three or more characters, followed by a closing character.


e.g.: ((\d{1,10}[,|.]*\d{0,10})*(\s)(\D{1,3})([$|\s|.|,|\)|/]+|  
$)) (untested)


If preg finds a match, it will pass an array to the specified  
function. In that function I evaluate the unit, see if it is in my  
array containing the conversion table. If that is the case,  
calculate the new value and return everything. Right?


I will get back with this new approach.

BTW, 0.32/0.34 seconds includes: calling the original html page from  
an outside server, loading this page into the DOM parser, walking  
through every table and every text string on that page. Convert  
everything necessary (the converter array contains about 14 metric -  
imperial converters) replace all converted DOM nodes and output  
everything. The metric / imperial calculations / replacements take  
between 0.00054 and 0.005 seconds per table cell / text string.


/frank

11 okt 2006 kl. 13.39 skrev Roman Neuhauser:


# [EMAIL PROTECTED] / 2006-10-11 09:52:51 +0200:


10 okt 2006 kl. 19.25 skrev Roman Neuhauser:


# [EMAIL PROTECTED] / 2006-10-09 22:01:34 +0200:

Thank you Ilaria and Roman for your input. I did not know that preg
is able to deal with PCRE patterns.


   preg is obviously short for Perl REGular expressions, while
   PCRE positively means Perl-Compatible Regular Expressions.
   The regexp syntax from Perl is a superset of POSIX extended
   regexps, so anything ereg_ function accept will be good for
   preg_ as well (but beware of pattern delimiters).


Thanks for the info. I didn't know that.


NP, glad to be of help. The relationship is quite obvious if you
look at both syntaxes.


As a matter of fact I came up
with the following solution (if someone is interested):


   What problem does it solve? I mean, why are you trying to avoid
   preg_replace_callback() in the first place?



Maybe because I didn't know better?


Well your question mentioned preg_replace_callback() so I thought
maybe there was something about the function you didn't like.

Initially, I was using  ereg_replace for replacing metric numbers  
with

imperial ones. But  obviously, ereg_replace replaces all instances in
the given text  string. A text containing more than one instance of
the same unit,  was replaced by the calculated replacement string of
the first  finding. So I had to think about other ways to do this -
which  brought me to preg_replace_callback (as I already said - I
didn't  know that preg takes POSIX patterns as well).

Would you suggest a different way? Would it be faster to do the
replacement with preg_replace_callback compared to the function I  
wrote?


Definitely, and probably by several orders of magnitude.


A page like this one: http://www.nikehydraulics.com/products/
product_chooser_gb.php?productMaingroup=5productSubgroup=33

.. gets converted within 0.32 / 0.34 seconds which I think is  
quite ok.


If the time covers only the conversion then it's quite terrible.

Looking at the convertTextString() function below there's a few
obvious optimizations waiting to be done, and... turning the  
foreach

into a single preg_replace_callback() is the one that begs
implementing the most (the code below's been tested and works):

class convertor
{
const SI_to_Imperial = 0;
const Imperial_to_SI = 1;

function convert($amount, $unit, $direction)
{
return sprintf(
whatever '%s' of '%s' is in the Imperial system
  , $amount
  , $unit
);
}
}
function callbackSI2IS(array $SIspec)
{
return convertor::convert(
$SIspec[1]
  , $SIspec[2]
  , convertor::SI_to_Imperial
);
}

$p = '~
((?:\d+[,|.])*\d+) # amount
\s*
(m{1,2}\b) # meters or millis
 ~x';
echo preg_replace_callback(
$p
  , 'callbackSI2IS'
  , file_get_contents('php://stdin')
);



the function takes a text and an array with converters like:

$converters[] = array ( metric = mm, imperial = in,
ratio  = 0.039370079, round = 1 );
$converters[] = array (	metric = m, imperial = ft,  
ratio

= 3.280839895, round = 1 );


function convertTextString ( $text, $convertTable )
{
# this function takes a text string, searches for numbers to
convert, convert those numbers and returns
# the complete text again.

if ( !ereg ( 

Re: [PHP] Re: moving to other web server

2006-10-11 Thread afan
no. there is no such variable name in my code.


 Afan Pasalic wrote:

 hi to all,
 we are moving our web server from one to other hosting company. we have
 chance to request what version of php i want to be installed, 4 or 5.
 Current web server works on php 4.3.4 we don't use any classes,
 functions only. as far as I know, in our case moving from 4 to 5
 shouldn't be any problem, no concerns. but, anyway, where can I expect
 errors - except in oop?

 thanks for any help.

 -afan

 If you currently use a variable named $this you can expect problems.


 Cheers
 --
 David Robley

 2 + 2 = 4 (for the time being).
 Today is Prickle-Prickle, the 65th day of Bureaucracy in the YOLD 3172.

 --
 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] Re: moving to other web server

2006-10-11 Thread Dave Goodchild

$this is a bad choice of variable name!


Re: [PHP] ereg_replace with user defined function?

2006-10-11 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-10-11 14:28:21 +0200:
 Actually, - believe it or not - I have never written a class (I am  
 still learning PHP after three years working with that language). So  
 I am not quite sure of the benefits of your class.

Nevermind then. I don't know how to fit my experience into a short
email, so I'm not going to explain it, just replace the class with
whatever pays the bill.

 Let me try to sum up:
 
 With a preg_replace_callback I am able to look for a pattern like: a  
 number ( float or integer ) followed by whitespace followed by one,  
 two, three or more characters, followed by a closing character.
 
 e.g.: ((\d{1,10}[,|.]*\d{0,10})*(\s)(\D{1,3})([$|\s|.|,|\)|/]+|$)) 
 (untested)

that's wrong unless you want e. g. these to match:

1|2|3|4 (^)
00|,. [EMAIL PROTECTED]
 
 If preg finds a match, it will pass an array to the specified  
 function. In that function I evaluate the unit, see if it is in my  
 array containing the conversion table. If that is the case,  
 calculate the new value and return everything. Right?

Yes.
 
 I will get back with this new approach.
 
 BTW, 0.32/0.34 seconds includes: calling the original html page from  
 an outside server, loading this page into the DOM parser

(...) ok then

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



RE: [PHP] Re: Understanding persistent connections with oci8

2006-10-11 Thread Bauer, Jay W
Hi Richard,

  Yes there have been some trigger-happy, bug-bogus-marking going on,
but that happens.

  And yes, this stays alive without anything going on.  And we have
tested your other wrinkle and that is how we have been able to end the
persistent connections by making connections to a non-oracle-db request
which will terminate the persistent connections.  The only other way has
been to restart apache.  And I can redo the test with just one server
and one connection and explicitly terminate the persistent connection by
making a new non-oracle-db request.

 Thanks and regards, Jay 

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 10, 2006 4:49 PM
To: Bauer, Jay W
Subject: RE: [PHP] Re: Understanding persistent connections with oci8

Excellent!

Submit that to bugs.php.net, and you have very good odds that it won't
get marked bogus and ignored.

You got caught in the net of trigger-happy bug-bogus-marking before,
right?

It happens, but if you check through the size/scale of the bugs db...

In this case, you've clearly shown that nothing else is keeping the
connection alive

Though, for one other wrinkle -- make some request after your timeout
that does not re-connect to the persistent connection.

It's possible that PHP cannot shutdown the connection after the timeout
unless it's being actively run by a non-db request, if you see what I
mean.

On Tue, October 10, 2006 2:01 pm, Bauer, Jay W wrote:
 Hello Richard,

   First let me introduce myself, I'm Jay Bauer and have been 
 supporting the Apache webserver for the last couple of years and have 
 been doing networking support for over 15 years.  I want to thank you 
 for explaining why the folks replying to our lab's enquiries don't 
 think the tests are valid.  I can appreciate the need of doing fault 
 isolation of a problem so that all possible extraneous causes are 
 eliminated.

   However, I don't think their specific concerns are valid, as these 
 systems are on internal networks, and very few people access them at 
 all, and only Kiran or I would be accessing the oracle database and 
 that is for our tests.  And yes we will get some 50 httpd servers up 
 and running, but once we stop our testing there is little access to 
 the system or none to these connections, and they will stay around for

 hours or days till one of us decides to do more testing and stops and 
 restarts the Apache server.

   Now having said all of that, I had no problem implementing the test 
 setup you suggested.  If that is what it takes to get everyone on the 
 same page, I'm happy to oblige.

  The HP-UX Apache web server only provides the worker MPM so in order 
 to set up Apache as requested we use the following configuration in
 httpd.conf:

  changed the worker.c configuration to:

 IfModule worker.c
 StartServers 1
 MaxClients   1
 MinSpareThreads  1
 MaxSpareThreads  1
 ThreadsPerChild  1
 MaxRequestsPerChild  1
 /IfModule

 and commented out mod_cgid:
 #LoadModule cgid_module modules/mod_cgid.so

 and in php.ini:

 extension=oci8.sl
 oci8.max_persistent=1
 oci8.persistent_timeout=10
 oci8.ping_interval=0

 After starting Apache we have two process running:

 ps -ef |grep apache
  www 29362 29361  0 23:39:52 ? 0:00
 /opt/hpws/apache/bin/httpd -d /opt/hpws/apache -k start
 root 29361 1  0 23:39:52 ? 0:00
 /opt/hpws/apache/bin/httpd -d /opt/hpws/apache -k start

 Pid 29361, the master httpd server, and one worker httpd server pid 
 29362, which is the minimum configuration possible with worker MPM.

  I then ran the apache bench mark for just one connection:

 bin/ab -n 1 http://maggie.india.hp.com/oracle_mufasa.php
 ...
 Document Path:  /oracle_mufasa.php
 Document Length:334 bytes

 Concurrency Level:  1
 Time taken for tests:   0.370606 seconds
 Complete requests:  1

 And then checked on the connection

 As quick as possible:
netstat -an |grep 1521
 tcp0  0  15.42.227.146.5926215.106.72.129.1521
 ESTABLISHED

 30 sends later:
netstat -an |grep 1521
 tcp0  0  15.42.227.146.5926215.106.72.129.1521
 ESTABLISHED

 2 minutes later:
netstat -an |grep 1521
 tcp0  0  15.42.227.146.5926215.106.72.129.1521
 ESTABLISHED

 5 minutes later:
netstat -an |grep 1521
 tcp0  0  15.42.227.146.5926215.106.72.129.1521
 ESTABLISHED

 It wasn't until about 40 minutes later that this connection did 
 finally terminate.

 And when I checked the error_log, it was clear what terminated it:

 [error] [client 15.10.45.59] Symbolic link not allowed:
 /opt/hpws/apache/htdocs/index.html
 [debug] worker.c(1342): taking over scoreboard slot from 29362
 (quiescing)

  Another request finally came in to this system , which errored, and 
 since there was only one server allowed to run it did and that is what
 killed this persistent connection.   This is what we have also
 observed
 that other apache requests 

Re: [PHP] Stored procs and transactions using Linux/PHP and Windows/MSSQL

2006-10-11 Thread Rick Emery

Quoting Chris [EMAIL PROTECTED]:


Rick Emery wrote:
Is anyone using PHP5 on Linux to connect to MS SQL Server 2000 on  
Windows and execute stored procedures with output parameters within  
a transaction? If so, how?


I'm trying to do something like this in the PHP application:

begin transaction
execute a stored procedure, receiving an identity back
if certain conditions are met
  execute another stored procedure, getting an identity
if certain other conditions are met
  execute another stored procedure, getting an identity
if any of the above procedures fail
  rollback transaction
else
  commit transaction


Can you do this in mssql (ie take php out of the picture) ?

That is - if you execute a procedure, can you get the identity back?

I have no idea about mssql but that would be my first check..


Let me first say that I got it working with php. While the dblib pdo  
driver doesn't support transactions, I was able to make this work  
using the mssql_* functions (though I had to get a little creative, as  
not all mssql data types are supported [bigint]).


Doing this all from sql was the first thing I tried, but there's a  
problem. The procedures that get called depend on the data that is  
available (from the posted page). To do this in a SQL stored  
procedure, where I have a fixed set of parameters, I would have a  
fixed amount of data I'd have to pass (even if empty).


Without getting into specifics of the application, an example would be  
that I need to add a business, with a person (or people) associated  
with the business, with phone numbers associated with the business and  
person/people. First, I call the stored procedure with the business  
information, then call the stored procedure that adds the business  
phone (multiple times if more than one phone), then call the stored  
procedure to add the person (calling for each person), then the stored  
procedure to add the person's/people's phone number(s). If any of  
those procedure calls fails, all should roll back (according to the  
design spec).


If I write a single stored procedure to call all of the others within  
a transaction, that's a lot of data to pass in. Not to mention that it  
might be dynamic...how many people/phone numbers should I expect to be  
passed?


Doing it inside php made things a lot easier.

Thanks for the suggestion,
Rick

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



Re: [PHP] Disable all caching

2006-10-11 Thread tedd

At 11:17 AM -0400 10/10/06, Benjamin Adams wrote:

I have a php (ver 4.x) script that is being cached.
I have placed:
META HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHE
but the page is still being cached.  I'm not sure if its apache or 
the php.  How can I disable all caching?

is there something I can set in php.ini?

(Mac OS X Server)

Thanks

Ben


Ben:

I use this:

?php # nocache.php
// this script prevents all caching

// expires on any past date
header (Expires: Mon, 26 Jul 1997 05:00: GMT);

// last modified at current date and time
header (Last-Modified:  . gmdate(D, d M Y H:i:s) . GMT);

// for HTTP 1.1:
header (Cache-Control: no-store, no-cache, must-revalidate);
header (Cache-Control: post-check=0, pre-check=0, false);

// for HTTP 1.0
header (Pragma: no-cache);
?

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



[PHP] Can i take the variable name in a function?

2006-10-11 Thread Jônata Tyska Carvalho

How can i take the variable name inside a function, ex:

definition:
function example( $ex ){
  echo Variable Name is $ex ;  // how to do this?
}

use:

example($ball);

output: Variable Name is ball;

another:

example($sportCar);

output: Variable Name is sportCar;

is that possible?



--
Jônata Tyska Carvalho
-
-- Técnico em Informática pelo Colégio Técnico Industrial (CTI)
-- Graduando em Engenharia de Computação
Fundação Universidade Federal de Rio Grande (FURG)


Re: [PHP] Re: moving to other web server

2006-10-11 Thread tedd

At 2:32 PM +0100 10/11/06, Dave Goodchild wrote:

$this is a bad choice of variable name!


$what is a bad choice of variable name?  :-)

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] Re: moving to other web server

2006-10-11 Thread Dave Goodchild

$this is


Re: [PHP] [JOB] PHP Book Tech Reviewer

2006-10-11 Thread tedd

At 3:53 PM -0400 10/10/06, Larry E. Ullman wrote:
I'm currently writing the second edition of my PHP Advanced book and 
need a technical reviewer. It is a paid job and some people think 
it's interesting/looks good on a resume/etc. Obviously you'll need 
to be an expert in PHP and pay close attention to detail. My 
definition of advanced for this book means:

- OOP
- Doing what you already do but better and faster
- Tangential topics (GD, PDFlib, CLI, PEAR, XML, Ajax, MySQL, 
E-Commerce, other buzzwords).

Experience in these areas required.

You must be able to work quickly (the entire book must be reviewed 
over the course of a month, I think). If you are interested or have 
any questions, please email me off-list.


Thanks,
Larry


Larry:

Looking forward to the book. Your other books have been exceptional.

Many thanks for your efforts.

tedd

PS: I wish I was qualified enough to help.
--
---
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 Mailer and SMTP = SPAM?

2006-10-11 Thread tedd

At 5:30 PM + 10/10/06, Roman Neuhauser wrote:

How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.


Troll.

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] Re: moving to other web server

2006-10-11 Thread afan
currently using mysql 4.0.18. want to move to 5.0 (latest stable version
for commercil use). is there anytihng I have to be considered DB will not
work?

thanks.



 no. there is no such variable name in my code.


 Afan Pasalic wrote:

 hi to all,
 we are moving our web server from one to other hosting company. we have
 chance to request what version of php i want to be installed, 4 or 5.
 Current web server works on php 4.3.4 we don't use any classes,
 functions only. as far as I know, in our case moving from 4 to 5
 shouldn't be any problem, no concerns. but, anyway, where can I expect
 errors - except in oop?

 thanks for any help.

 -afan

 If you currently use a variable named $this you can expect problems.


 Cheers
 --
 David Robley

 2 + 2 = 4 (for the time being).
 Today is Prickle-Prickle, the 65th day of Bureaucracy in the YOLD 3172.

 --
 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: Understanding persistent connections with oci8

2006-10-11 Thread Bauer, Jay W
 Hello everyone,

  I followed up on Richards suggested new-wrinkle and automated the
time recording a bit better than before.  Here is what I did and the
results:

This time I first enabled the access_log on maggie, so I had that
history, and used browser windows to connect to
http://maggie.india.hp.com/oracle_mufasa.php to set up a persistent
connection and then about 15 minutes later in another browser connect to
http://maggie.india.hp.com/.  Within that time there were no other
attempts to connect to the web server.  The access_log gives the times
quite clearly:

/opt/hpws/apachemore logs/access_log
16.113.41.14 - - [11/Oct/2006:20:16:03 +0530] GET /oracle_mufasa.php
HTTP/1.1 200 334
16.113.41.14 - - [11/Oct/2006:20:31:52 +0530] GET / HTTP/1.1 200 1456
16.113.41.14 - - [11/Oct/2006:20:31:53 +0530] GET /apache_pb.gif
HTTP/1.1 200 2326

And the error_log entry is the same as seen in the test yesterday when
the persistent connection was terminated by a random request.  It is
good to confirm that under this restricted configuration those are the
errors we are getting:

/opt/hpws/apachetail logs/error_log  
...
[Wed Oct 11 20:31:52 2006] [error] [client 16.113.41.14] Symbolic link
not allowed: /opt/hpws/apache/htdocs/index.html
[Wed Oct 11 20:31:53 2006] [debug] worker.c(1342): taking over
scoreboard slot from 11077 (quiescing)
[Wed Oct 11 20:31:53 2006] [debug] util_ldap.c(1697): Initialisation of
global mutex /opt/hpws/apache/ in child process 11267 successful.

  And using date and netstat we see the persistent connection stay
ESTABLISHED till the second non-oracle-db request comes in:

/user/jwbaudate
Wed Oct 11 20:17:34 IST 2006
/user/jwbaunetstat -an|grep 1521
tcp0  0  15.42.227.146.6236515.106.72.129.1521
ESTABLISHED
/user/jwbaudate
Wed Oct 11 20:21:26 IST 2006
/user/jwbaunetstat -an|grep 1521
tcp0  0  15.42.227.146.6236515.106.72.129.1521
ESTABLISHED
/user/jwbaudate
Wed Oct 11 20:21:45 IST 2006
/user/jwbaunetstat -an|grep 1521
tcp0  0  15.42.227.146.6236515.106.72.129.1521
ESTABLISHED
/user/jwbaudate
Wed Oct 11 20:23:20 IST 2006
/user/jwbaunetstat -an|grep 1521
tcp0  0  15.42.227.146.6236515.106.72.129.1521
ESTABLISHED
/user/jwbaudate
Wed Oct 11 20:25:09 IST 2006
/user/jwbaunetstat -an|grep 1521
tcp0  0  15.42.227.146.6236515.106.72.129.1521
ESTABLISHED
/user/jwbaudate
Wed Oct 11 20:31:21 IST 2006
/user/jwbaunetstat -an|grep 1521
tcp0  0  15.42.227.146.6236515.106.72.129.1521
TIME_WAIT
/user/jwbaudate
Wed Oct 11 20:32:11 IST 2006
/user/jwbaunetstat -an|grep 1521
tcp0  0  15.42.227.146.6236515.106.72.129.1521
TIME_WAIT
/user/jwbaudate
Wed Oct 11 20:33:35 IST 2006
/user/jwbaunetstat -an|grep 1521

  I'll put this and the data from yesterday together and submit it to
bugs.php.net.

 Best regards, Jay 

-Original Message-
From: Bauer, Jay W 
Sent: Wednesday, October 11, 2006 9:46 AM
To: [EMAIL PROTECTED]; 'php-general@lists.php.net'
Cc: '[EMAIL PROTECTED]'; Mendonce, Kiran (STSD); Nikiel, Carsten; Rai,
Moni (GSE WTEC Cupertino); Rieslund, Mikael
Subject: RE: [PHP] Re: Understanding persistent connections with oci8

Hi Richard,

  Yes there have been some trigger-happy, bug-bogus-marking going on,
but that happens.

  And yes, this stays alive without anything going on.  And we have
tested your other wrinkle and that is how we have been able to end the
persistent connections by making connections to a non-oracle-db request
which will terminate the persistent connections.  The only other way has
been to restart apache.  And I can redo the test with just one server
and one connection and explicitly terminate the persistent connection by
making a new non-oracle-db request.

 Thanks and regards, Jay 

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 10, 2006 4:49 PM
To: Bauer, Jay W
Subject: RE: [PHP] Re: Understanding persistent connections with oci8

Excellent!

Submit that to bugs.php.net, and you have very good odds that it won't
get marked bogus and ignored.

You got caught in the net of trigger-happy bug-bogus-marking before,
right?

It happens, but if you check through the size/scale of the bugs db...

In this case, you've clearly shown that nothing else is keeping the
connection alive

Though, for one other wrinkle -- make some request after your timeout
that does not re-connect to the persistent connection.

It's possible that PHP cannot shutdown the connection after the timeout
unless it's being actively run by a non-db request, if you see what I
mean.

On Tue, October 10, 2006 2:01 pm, Bauer, Jay W wrote:
 Hello Richard,

   First let me introduce myself, I'm Jay Bauer and have been 
 supporting the Apache webserver for the last couple of years and have 
 been doing networking support for over 15 years.  I want to thank you 
 for explaining why the folks replying to our lab's enquiries don't 
 think the tests are valid.  I can 

Re: [PHP] Question about Arrays

2006-10-11 Thread tedd

At 7:04 PM +0100 10/10/06, Alex Major wrote:

Hi List.
I have a table, which contains 'setting' information for my website.
The table has the following columns: setting_id, setting_name and 
setting_value.
Now there are currently 30 settings stored in this table, however i 
am having trouble pulling values out on a 'as needed' basis.


At the moment i have this select query:
$settings_query = SELECT * FROM `robin_settings`;
$settings_result = mysql_query($settings_query);

And from that, i would like to pull individual results, for example...

I have a setting which has a 'setting_id' of 4, a 'setting_name' 
called banner_on and a 'setting_value' of  1.


How am i able to pull that information from the results i get?

I know i could pull it by putting a WHERE clause on the SQL query, 
however that would mean having 30 select queries per page and i 
don't really fancy that!


Thanks for any help! (i'm new at this :) )

Alex.



Alex:

I'm not trying to be a smart ass, but it might help if you look at 
the manual. If in doubt, always try looking up the function you are 
using (like mysql_query() ) and see what it does and how it works in 
the examples, like so:


http://us3.php.net/manual/en/function.mysql-query.php

To give you a hint as to your question, the variable 
$settings_result above is a resource where using another function 
mysql_fetch_array() will pull out what you want.


hth's

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] moving to other web server

2006-10-11 Thread Jochem Maas
Afan Pasalic wrote:
 hi to all,
 we are moving our web server from one to other hosting company. we have
 chance to request what version of php i want to be installed, 4 or 5.
 Current web server works on php 4.3.4 we don't use any classes,
 functions only. as far as I know, in our case moving from 4 to 5
 shouldn't be any problem, no concerns. but, anyway, where can I expect
 errors - except in oop?

calltime pass by reference is depreciated

 
 thanks for any help.
 
 -afan
 

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



Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Jochem Maas
Jônata Tyska Carvalho wrote:
 How can i take the variable name inside a function, ex:
 
 definition:
 function example( $ex ){
   echo Variable Name is $ex ;  // how to do this?
 }
 
 use:
 
 example($ball);
 
 output: Variable Name is ball;
 
 another:
 
 example($sportCar);
 
 output: Variable Name is sportCar;
 
 is that possible?

no.

 
 
 

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



Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Andy Hultgren

Would something like this work?

Definition:
function example($$ex) {
  echo Variable Name is $ex;
}

example($ball);


I'm fairly new to php and not so familiar with variable variables, but I
thought I'd throw it out there as a thought!

Andy


On 10/11/06, Jochem Maas [EMAIL PROTECTED] wrote:


Jônata Tyska Carvalho wrote:
 How can i take the variable name inside a function, ex:

 definition:
 function example( $ex ){
   echo Variable Name is $ex ;  // how to do this?
 }

 use:

 example($ball);

 output: Variable Name is ball;

 another:

 example($sportCar);

 output: Variable Name is sportCar;

 is that possible?

no.





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




Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Jochem Maas
Andy Hultgren wrote:
 Would something like this work?

did you try it? ;-)
it won't work

  
 Definition:
 function example($$ex) {
echo Variable Name is $ex;
 }
  
 example($ball);
 
  
 I'm fairly new to php and not so familiar with variable variables, but I
 thought I'd throw it out there as a thought!
  
 Andy
 
  
 On 10/11/06, *Jochem Maas* [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED] wrote:
 
 Jônata Tyska Carvalho wrote:
  How can i take the variable name inside a function, ex:
 
  definition:
  function example( $ex ){
echo Variable Name is $ex ;  // how to do this?
  }
 
  use:
 
  example($ball);
 
  output: Variable Name is ball;
 
  another:
 
  example($sportCar);
 
  output: Variable Name is sportCar;
 
  is that possible?
 
 no.
 
 
 
 
 
 --
 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] Can i take the variable name in a function?

2006-10-11 Thread Andy Hultgren

u no... I suppose I should have though! :)

On 10/11/06, Jochem Maas [EMAIL PROTECTED] wrote:


Andy Hultgren wrote:
 Would something like this work?

did you try it? ;-)
it won't work


 Definition:
 function example($$ex) {
echo Variable Name is $ex;
 }

 example($ball);


 I'm fairly new to php and not so familiar with variable variables, but I
 thought I'd throw it out there as a thought!

 Andy


 On 10/11/06, *Jochem Maas* [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED] wrote:

 Jônata Tyska Carvalho wrote:
  How can i take the variable name inside a function, ex:
 
  definition:
  function example( $ex ){
echo Variable Name is $ex ;  // how to do this?
  }
 
  use:
 
  example($ball);
 
  output: Variable Name is ball;
 
  another:
 
  example($sportCar);
 
  output: Variable Name is sportCar;
 
  is that possible?

 no.

 
 
 

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






Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Andy Hultgren

Check this out: http://www.php.net/manual/en/functions.arguments.php

Specifically this example:

Making arguments be passed by reference

By default, function arguments are passed by value (so that if you change
the value of the argument within the function, it does not get changed
outside of the function). If you wish to allow a function to modify its
arguments, you must pass them by reference.

If you want an argument to a function to always be passed by reference, you
can prepend an ampersand () to the argument name in the function
definition:

  *Example 17-6. Passing function parameters by reference*
 ?php
function add_some_extra($string)
{
  $string .= 'and something extra.';
}
$str = 'This is a string, ';
add_some_extra($str);
echo $str;// outputs 'This is a string, and something extra.'
?
I think that does what you want?

Andy


On 10/11/06, Jônata Tyska Carvalho [EMAIL PROTECTED] wrote:


I know that function does not work, but im asking if someone know a way to
do that.

Someone know how ???

On 10/11/06, Andy Hultgren  [EMAIL PROTECTED] wrote:

 u no... I suppose I should have though! :)

 On 10/11/06, Jochem Maas [EMAIL PROTECTED]  wrote:
 
  Andy Hultgren wrote:
   Would something like this work?
 
  did you try it? ;-)
  it won't work
 
  
   Definition:
   function example($$ex) {
  echo Variable Name is $ex;
   }
  
   example($ball);
  
  
   I'm fairly new to php and not so familiar with variable variables,
  but I
   thought I'd throw it out there as a thought!
  
   Andy
  
  
   On 10/11/06, *Jochem Maas*  [EMAIL PROTECTED]
   mailto: [EMAIL PROTECTED] wrote:
  
   Jônata Tyska Carvalho wrote:
How can i take the variable name inside a function, ex:
   
definition:
function example( $ex ){
  echo Variable Name is $ex ;  // how to do this?
}
   
use:
   
example($ball);
   
output: Variable Name is ball;
   
another:
   
example($sportCar);
   
output: Variable Name is sportCar;
   
is that possible?
  
   no.
  
   
   
   
  
   --
   PHP General Mailing List ( http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 
 



--
Jônata Tyska Carvalho
-
-- Técnico em Informática pelo Colégio Técnico Industrial (CTI)
-- Graduando em Engenharia de Computação
Fundação Universidade Federal de Rio Grande (FURG)


Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Eric Butera

On 10/11/06, Andy Hultgren [EMAIL PROTECTED] wrote:

  ?php
function add_some_extra($string)
{
   $string .= 'and something extra.';
}
$str = 'This is a string, ';
add_some_extra($str);
echo $str;// outputs 'This is a string, and something extra.'
?
I think that does what you want?


In the add_some_extra example you gave he wants the named value of the
passed parameter which is $str.

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



Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Eric Butera

On 10/11/06, Paul Scott [EMAIL PROTECTED] wrote:


On Wed, 2006-10-11 at 13:19 -0400, Eric Butera wrote:

 In the add_some_extra example you gave he wants the named value of the
 passed parameter which is $str.


Isn't that what the Reflection API is there for?

--Paul



All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm




I don't see anything on ReflectionFunction that would give the string
value of the variable that is passed as a parameter.

function add_some_extra($string) {
  $string .= 'and something extra.';
}
$str = 'This is a string, ';
add_some_extra($str);

You can $string, but not $str as far as I know.

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



Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Paul Scott

On Wed, 2006-10-11 at 13:19 -0400, Eric Butera wrote:

 In the add_some_extra example you gave he wants the named value of the
 passed parameter which is $str.
 

Isn't that what the Reflection API is there for?

--Paul

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm 

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

[PHP] gd for php5 under RH ES4

2006-10-11 Thread Doug Fulton
I am trying to use the php gd library (for imagecreate, etc) with php5 
under Red Hat ES4.  I tried installing php-gd via webmin (which in turn, 
I see, uses up2date), but get the following error in the apache error 
log when restarting:
PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/lib/php4/gd.so' - /usr/lib/php4/gd.so: undefined symbol: 
empty_string in Unknown on line 0

I don't know if the problem is that php-gd is a php4 library or there is 
something else that I need to install or do.  I saw something about 
php5-gd, but webmin/up2date can't find anything by this name.

I have searched for a bit on this without joy; any guidance is 
appreciated.  I am not a system administrator by training, but am a 
longtime Unix programmer, so I can handle reasonably low level 
instructions, if necessary.  I did post this to a Red Hat list without 
any reply so far.

Thanks in advance,
Doug

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



[PHP] Re: [GD-DEVEL] gd for php5 under RH ES4

2006-10-11 Thread Antony Dovgal

On 10/11/2006 10:36 PM, Doug Fulton wrote:
I am trying to use the php gd library (for imagecreate, etc) with php5 
under Red Hat ES4.  I tried installing php-gd via webmin (which in turn, 
I see, uses up2date), but get the following error in the apache error 
log when restarting:
PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/lib/php4/gd.so' - /usr/lib/php4/gd.so: undefined symbol: 
empty_string in Unknown on line 0


I don't know if the problem is that php-gd is a php4 library 


Yes, gd.so apparently was built using headers from PHP4 or PHP5.0.x, this is 
the cause of your problem.

or there is 
something else that I need to install or do.  I saw something about 
php5-gd, but webmin/up2date can't find anything by this name.


I have searched for a bit on this without joy; any guidance is 
appreciated.  I am not a system administrator by training, but am a 
longtime Unix programmer, so I can handle reasonably low level 
instructions, if necessary.  I did post this to a Red Hat list without 
any reply so far.



--
Wbr, 
Antony Dovgal


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



Re: [PHP] gd for php5 under RH ES4

2006-10-11 Thread Richard Lynch
On Wed, October 11, 2006 1:36 pm, Doug Fulton wrote:
 I am trying to use the php gd library (for imagecreate, etc) with php5
 under Red Hat ES4.  I tried installing php-gd via webmin (which in
 turn,
 I see, uses up2date), but get the following error in the apache error
 log when restarting:
 PHP Warning:  PHP Startup: Unable to load dynamic library
 '/usr/lib/php4/gd.so' - /usr/lib/php4/gd.so: undefined symbol:
 empty_string in Unknown on line 0

 I don't know if the problem is that php-gd is a php4 library or there
 is
 something else that I need to install or do.  I saw something about
 php5-gd, but webmin/up2date can't find anything by this name.

 I have searched for a bit on this without joy; any guidance is
 appreciated.  I am not a system administrator by training, but am a
 longtime Unix programmer, so I can handle reasonably low level
 instructions, if necessary.  I did post this to a Red Hat list without
 any reply so far.

The way I see it, you have 2 choices:

#1. Convince webmin and/or up2date and/or RedHat to fix their broken
installer dependencies.

#2. Compile the PHP GD extension, and GD itself probably, from source.

Actually, you could dink around some more with up2date to be sure you
have GD itself installed first -- That might be the problem, and would
be trivial to fix.

There are 3 pieces to this puzzle that you must install and also match
up version-wise:
GD
PHP
PHP GD extension

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Richard Lynch
On Wed, October 11, 2006 9:58 am, Jônata Tyska Carvalho wrote:
 How can i take the variable name inside a function, ex:

 definition:
 function example( $ex ){
echo Variable Name is $ex ;  // how to do this?
 }

 use:

 example($ball);

 output: Variable Name is ball;

 another:

 example($sportCar);

 output: Variable Name is sportCar;

 is that possible?

Not really.

Its local name is not all that interesting/useful anyway.

Most beginners who go down this path are taking something simple and
turning it 90 degrees on its head and making it all complicated...

What are you really trying to do, and why?

If you really really really know what you are doing, you can do this:

function example($name){
  global $name;

  echo The variable $name has the value: , $$name;
}

Read http://php.net section about Variable variables for more info.

Note that using $$variable is almost always an indication of a
mis-guided attempt to do something else, and is very likely to open up
security implications, plus usually involves using 'global' which
makes debugging/maintenance a nightmare.

The usual answer, once we find out what the programmer is REALLY
trying to do, is:

Usa an array!

function example($values){
  foreach($values as $name = $value){
echo $name: $valuebr /\n;
  }
}

example(array('sportsCar'='Mazzeratti'));

Apologies in advance for probably mis-spelling the only sports car
name I could think of...

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Richard Lynch
On Wed, October 11, 2006 12:19 pm, Eric Butera wrote:
 On 10/11/06, Andy Hultgren [EMAIL PROTECTED] wrote:
   ?php
 function add_some_extra($string)
 {
$string .= 'and something extra.';
 }
 $str = 'This is a string, ';
 add_some_extra($str);
 echo $str;// outputs 'This is a string, and something extra.'
 ?
 I think that does what you want?

 In the add_some_extra example you gave he wants the named value of the
 passed parameter which is $str.

Maybe.

Or maybe he wants 'string' which is the local variable name.

Or, given the way software projects go, maybe he wanted the name of
the variable from 5 function stack-calls back...

Which is why I said it's generally not all that useful, since any
given variable takes on a variety of names as it gets passed around
in a web application.

Obviously a well-structured application will keep the name consistent
within a single API layer or class or module or script or whatever
unit of code it makes sense to be consistent.

But, still, sooner or later, either in the script or the guts of PHP,
al your string variables end up being named 'string' which is just not
that useful to report, when you get right down to it...  Since maybe
it's really $password or maybe it's really $username or maybe it's
$comment in the main script.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



RE: [PHP] Re: Understanding persistent connections with oci8

2006-10-11 Thread Richard Lynch
On Wed, October 11, 2006 8:46 am, Bauer, Jay W wrote:
   Yes there have been some trigger-happy, bug-bogus-marking going on,
 but that happens.

   And yes, this stays alive without anything going on.  And we have
 tested your other wrinkle and that is how we have been able to end
 the
 persistent connections by making connections to a non-oracle-db
 request
 which will terminate the persistent connections.  The only other way
 has
 been to restart apache.  And I can redo the test with just one server
 and one connection and explicitly terminate the persistent connection
 by
 making a new non-oracle-db request.

Okay, so here's the thing...

At what point in the process of normal web-server operations would you
expect PHP to notice that the connection is stale and it should die?

It's clear, to me, and to many others, that the problem here is not
that it doesn't work -- Just that it works in a non-intuitive way
for perfectly logical technical reasons.

To clarify this, consider your one-process, one-user, one-hit test.

Time
00:00 User asks for URL that accesses DB
00:01 PHP opens persistent connection
00:02 PHP returns HTML to user
[It's probably not really 2 seconds, but let's just pretend.]

At this juncture, Apache and PHP pretty much just go back to sleep,
and don't do anything at all until something else comes along to wake
them up.

If the next thing to wake them up authenticates against the DB, and
starts using the connections, then they are re-used, because they are
already there, and there is no sense in tearing down a perfectly good
stale connection if you're about to build another one.

If the next thing to wake them up does NOT use the DB connection, the
connection is noticed to be stale and killed off.

This is how it works, as far as we can see from your testing.

So there are several possible solutions here.

PHP could set some kind of timer to wake itself up, check any
outstanding persistent connections, and kill them off.  This would
need to be managed so that there is only one active timer and its
wake-up time is extended as various events occur, since you wouldn't
want it doing too much extra work that PHP is already doing.

That would probably involve a great deal of inter-process
communication and some significant overhead.

The other option, cheap and easy, is to behave the way it does now: 
If somebody wakes PHP up, and it sees a stale connection, and it's not
gonna use that stale connection, it kills it off.

Now for MOST users, on MOST real-life scenarios, the cheap and easy
solution is best.

For those who have an unusual case, such as your dev server, a cron
job to heartbeat a non-DB page every X minutes is a no-brainer, once
one understands what's going on and why.

You are certainly welcome to code and submit a patch to PHP to make it
wake up and kill off stale connections, if you really think this is
absolutely crucial...  But if it has the kind of overhead I suspect it
would have, it's not likely to be implemented.

Or you could run a heartbeat cron job to a non-DB connection just a
little bit longer than your connection time-out, and call the problem
solved.

NOTE:
I am NOT an expert on PHP internals, and may be grossly incorrect
about all this.  I'm just giving my perception of your test results,
based on how HTTP / Apache/ PHP generally work.

PS I think this is how all the persistent connections operate...

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-11 Thread Richard Lynch
On Tue, October 10, 2006 6:14 pm, Chris de Vidal wrote:
 I want to create a customer class which fetches its attributes from
 a MySQL database.

No, you don't. :-)

This is a classic example of the obvious OOP solution being wildly
inappropriate.

The sad thing is, there are a zillion applications out there doing it
just this way... :-(

Start thinking more in terms of what you want the whole application to
do, and build classes that do THAT, rather then starting with a single
customer and their info.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Richard Lynch
On Wed, October 11, 2006 2:21 pm, Richard Lynch wrote:
 If you really really really know what you are doing, you can do this:

And if you make no typos like I just did... :-)

 function example($name){
//  global $name; //Whoops!

global $$name; //note the TWO $ symbols!


   echo The variable $name has the value: , $$name;
 }

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Working with overly aggressive anti-spam measures [SOLVED]

2006-10-11 Thread Richard Lynch
On Tue, October 10, 2006 8:57 pm, Dave M G wrote:
 It took me a little while to realize that the Spamassassin always says
 that an email is possible scam if it has any score above zero, but it
 takes a score of 5.0 to actually be deleted as spam. I checked through
 a
 bunch of emails in my inbox, and all of them got at least some score,
 usually between .5 and 1.5, even though they were all legitimate
 emails.

That 5.0 is user-configurable -- In fact, for my Inbox, 3.0 or above
is sent direct to trash.

I spent a month or two with 10 filters sending every message to one of
10 boxes:
Inbox.1
Inbox.2
Inbox.3
...
Inbox.10

As time went on, I found that only 1 and 2 scores were worth digging
through, and lowered my SA setting to 3 and above is just auto-trash.

And a couple mailing lists were going to higher scores, but those were
easily white-listed.

This would have been much easier had the email client let me sort by
SA score, but that feature has apparently not been invented yet...

YMMV, but it's amazing how much less spam I got once I let SA kill off
all the junk it was pre-configured to accept.

Course, I'm sure I'm losing some legit email as well, but it's such a
tiny percentage, I just can't get too worked up about it.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-11 Thread Stut

Richard Lynch wrote:

On Tue, October 10, 2006 6:14 pm, Chris de Vidal wrote:

I want to create a customer class which fetches its attributes from
a MySQL database.


No, you don't. :-)

This is a classic example of the obvious OOP solution being wildly
inappropriate.


Ok, so I now find myself in the unusual position of disagreeing with the 
Lynchmeister. Why is this wildly inappropriate? IMHO this is what OOP is 
all about.


You can encapsulate everything to do with a customer in an object. This 
ensures that you don't duplicate any code that works on customer data. 
You avoid duplication of code. As a result you can ensure data integrity 
because there is only one route to read and write it.


If this is not what you think OOP is all about, do please enlighten us 
as to the error of our ways.


-Stut

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



RE: [PHP] Re: Understanding persistent connections with oci8

2006-10-11 Thread Bauer, Jay W
 Hi Richard,

  You've asked the $64,000 question.  What is a reasonable way for this
timeout to work?  Unfortunately we haven't gotten  far with the
bug.php.net folks to ask the question.  I agree with you that providing
an active thread or process to go out and check for idle persistent
connections is too much overhead. 
I think what is needed is a little investigation to see what can be
reasonable done if a customer wants to use the oci8.persistent_timeout
to limit how long these connections hang around.  

  From our testing of multiple connections we could easily create 50 of
these persistent connections and would have to hit the apache web server
pretty hard with a 1000 requests at 50 at a time to get these to
terminate after the timeout.But that does work, so that is one data
point and limit when setting this idle timeout.  What I think should
also happen if the timeout is set, and the persistent connection goes
idle long enough it should be marked as a candidate for shutting down.
PHP itself if it goes to use this stale connection, should kill it and
use another connection, hopefully a non-stale persistent connection.

  And actually, Kiran in our lab proposed that as a very easy fix to
implement, and we've tested it and it works fine.  In other words we
make 50 persistent connections, with the timeout at 10 seconds, wait a
minute and then make another round of the same php requests.  With the
fix we proposed all new php connections are made.  So we know this
works.  I think if this was implemented and the documentation was clear
that what the persistent timeout provided was for these connections to
be shutdown when every a new connection tried to use them, PHP or not,
that would go along way to satisfying most customers.  Especially if it
clearly and cleanly documented that was how it worked.

  I can also see environments where the system hosting apache and these
persistent connections for the database is very busy, and can get large
burst of PHP requests from different users accessing the data at a given
time, which creates lots of persistent connections.  I can see them
wanting a more active mechanism for terminating any connections after
the peak has ended and thinks have quieted down for awhile.   I think
your idea of a cron job might work there, or the same mechanism within
PHP.  If there was one, I'd make it optional as it would be overhead and
many customers wouldn't want it.

  There seems to me to be several ways to implement this
persistent_timeout that would make it act like how most idle timeouts
work, and I agree if we can come up with some simple, low overhead ways
that are well documented that would do the trick.


 Thanks and regards, Jay 
   
  

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 11, 2006 3:44 PM
To: Bauer, Jay W
Cc: php-general@lists.php.net; Bauer, Jay W; Mendonce, Kiran (STSD);
Nikiel, Carsten; Rai, Moni (GSE WTEC Cupertino); Rieslund, Mikael
Subject: RE: [PHP] Re: Understanding persistent connections with oci8

On Wed, October 11, 2006 8:46 am, Bauer, Jay W wrote:
   Yes there have been some trigger-happy, bug-bogus-marking going on, 
 but that happens.

   And yes, this stays alive without anything going on.  And we have 
 tested your other wrinkle and that is how we have been able to end 
 the persistent connections by making connections to a non-oracle-db 
 request which will terminate the persistent connections.  The only 
 other way has been to restart apache.  And I can redo the test with 
 just one server and one connection and explicitly terminate the 
 persistent connection by making a new non-oracle-db request.

Okay, so here's the thing...

At what point in the process of normal web-server operations would you
expect PHP to notice that the connection is stale and it should die?

It's clear, to me, and to many others, that the problem here is not that
it doesn't work -- Just that it works in a non-intuitive way for
perfectly logical technical reasons.

To clarify this, consider your one-process, one-user, one-hit test.

Time
00:00 User asks for URL that accesses DB
00:01 PHP opens persistent connection
00:02 PHP returns HTML to user
[It's probably not really 2 seconds, but let's just pretend.]

At this juncture, Apache and PHP pretty much just go back to sleep, and
don't do anything at all until something else comes along to wake them
up.

If the next thing to wake them up authenticates against the DB, and
starts using the connections, then they are re-used, because they are
already there, and there is no sense in tearing down a perfectly good
stale connection if you're about to build another one.

If the next thing to wake them up does NOT use the DB connection, the
connection is noticed to be stale and killed off.

This is how it works, as far as we can see from your testing.

So there are several possible solutions here.

PHP could set some kind of timer to wake itself up, check any
outstanding 

Re: [PHP] PHP Mailer and SMTP = SPAM?

2006-10-11 Thread Google Kreme

On 10 Oct 2006, at 12:37 , Richard Lynch wrote:

Very simple to code/implement/maintain.


Oh?  How simple is it?

(yes, this is an oblique request for code :)

--  
Nothing like grilling a kosher dog over human hair to bring out the  
subtle flavors.


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



[PHP] PHP 5 Hosting

2006-10-11 Thread Ed Lazor
Anyone ever use A2Hosting.com?  Or better yet, any recommendations on  
a PHP 5 web hosting company that you're happy with - measured in  
terms of quality support, they know what they're doing, and they have  
good prices?  Bonus points for good drive space, bandwidth, and SSH  
access.


I ran a Google search and came up with several options.   
A2Hosting.com seems the best so far.  My only reservation is that  
they offer 24/7 support through a message service who will page a  
tech who in turn will call you back - seems sketchy and I can imagine  
trying to talk someone into going to the server room at 2am.  I also  
checked out many of the other options, but some of them seemed even  
more sketchy... like VisualWebHosting.com...  you click on their link  
for a BBB review and it brings up another company entirely... and you  
call their number and all the greeting says is Please leave a  
message... bep... pretty scary if you ask me.


Anyway, thanks in advance for any recommendations you have.

-Ed

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



Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Jônata Tyska Carvalho

i know what i want to do, and im not a rookie in php.

example of a use:

debug($vetNames);

output:

The variable vetNames has the follow properties:

key1 = value1,
key2 = value2



just one example. need it for another things.

On 10/11/06, Richard Lynch [EMAIL PROTECTED] wrote:


On Wed, October 11, 2006 2:21 pm, Richard Lynch wrote:
 If you really really really know what you are doing, you can do this:

And if you make no typos like I just did... :-)

 function example($name){
//  global $name; //Whoops!

global $$name; //note the TWO $ symbols!


   echo The variable $name has the value: , $$name;
 }

--
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?





--
Jônata Tyska Carvalho
-
-- Técnico em Informática pelo Colégio Técnico Industrial (CTI)
-- Graduando em Engenharia de Computação
Fundação Universidade Federal de Rio Grande (FURG)


Re: [PHP] Re: Understanding persistent connections with oci8

2006-10-11 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-10-11 16:42:06 -0400:
   And actually, Kiran in our lab proposed that as a very easy fix to
 implement, and we've tested it and it works fine.  In other words we
 make 50 persistent connections, with the timeout at 10 seconds, wait a
 minute and then make another round of the same php requests.  With the
 fix we proposed all new php connections are made.  So we know this
 works.  I think if this was implemented and the documentation was clear
 that what the persistent timeout provided was for these connections to
 be shutdown when every a new connection tried to use them, PHP or not,
 that would go along way to satisfying most customers.  Especially if it
 clearly and cleanly documented that was how it worked.

That's not so much a fix as a different behavior. FWIW the current
one is perfectly sensible in other circumstances.

Is there a way to query the age of the connection?

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Robert Cummings
On Wed, 2006-10-11 at 19:02 -0300, Jônata Tyska Carvalho wrote:
 i know what i want to do, and im not a rookie in php.
 
 example of a use:
 
 debug($vetNames);
 
 output:
 
 The variable vetNames has the follow properties:
 
 key1 = value1,
 key2 = value2

Example:

?php

function fooA( $fooA )
{
return fooB( $fooA );
}

function fooB( $fooB )
{
return fooC( $fooB );
}

function fooC( $fooC )
{
return fooD( $fooC );
}

function fooD( $fooD )
{
return fooE( $fooD );
}

function fooE( $fooE )
{
return fooF( $fooE );
}

function fooF( $fooF )
{
debug( $fooF );
}

fooA();

?

So the question is... what name do you want? :B

And if you say 'fooF', then that's when you're calling the debug()
function so pass it yourself. Otherwise, you have a dilemma, and it sure
as hell isn't PHP's responsibility to forward the ancestry of names to
your debug function :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Re: moving to other web server

2006-10-11 Thread Chris

[EMAIL PROTECTED] wrote:

currently using mysql 4.0.18. want to move to 5.0 (latest stable version
for commercil use). is there anytihng I have to be considered DB will not
work?


I really suggest you set up a test box (even if it's an unused desktop - 
they work great for development machines) and *test* your application in 
the new environment settings.


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-11 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-10-11 21:28:36 +0100:
 Richard Lynch wrote:
 On Tue, October 10, 2006 6:14 pm, Chris de Vidal wrote:
 I want to create a customer class which fetches its attributes from
 a MySQL database.
 
 No, you don't. :-)
 
 This is a classic example of the obvious OOP solution being wildly
 inappropriate.
 
 Ok, so I now find myself in the unusual position of disagreeing with the 
 Lynchmeister. Why is this wildly inappropriate? IMHO this is what OOP is 
 all about.

No, that's what trivial OOP examples applied to the letter where
a different approach is in order are. If you study the GoF book [GoF]
you'll see that the traditional claim objects model physical
entities from real world (and nothing else) is very simplistic
and terribly limiting.

[GoF] http://www.amazon.com/dp/0201633612/

If you paint yourself into this corner you'll find your code
grinding the database to death in the OO-relational impedance
mismatch. The OOP ideal of a single source of data is nice,
unfortunately the real world gets in the way.
 
 You can encapsulate everything to do with a customer in an object. This 
 ensures that you don't duplicate any code that works on customer data. 
 You avoid duplication of code. As a result you can ensure data integrity 
 because there is only one route to read and write it.
 
Who talks about duplicating business logic? You just need to have
more than one access point for the data.

 If this is not what you think OOP is all about, do please enlighten us 
 as to the error of our ways.

Imagine deleting many rows in a table one by one (pseudocode):

class Record
{
function __construct($id)
{
$this-id = $id;
}
function delete()
{
// DELETE FROM some_table WHERE id = $this-id
}
}
foreach ($records as $r) {
$r-delete();
}

instead of taking them with a single DELETE:

// assuming
// class Search;
// $searchBuilder = new SearchBuilder;
// $SearchBuilder-add(new LessThan('id', '501'));
// $search = $searchBuilder-result();

class RecordSet
{
function __construct(Search $search)
{
$this-search = $search;
}
function delete()
{
// DELETE FROM some_table WHERE $this-search-toSQL()
}
}

$recordset($search);
$recordset-delete();

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Re: moving to other web server

2006-10-11 Thread Afan Pasalic

right. that would be actually the best thing to do.
thanks.



Chris wrote:

[EMAIL PROTECTED] wrote:

currently using mysql 4.0.18. want to move to 5.0 (latest stable version
for commercil use). is there anytihng I have to be considered DB will 
not

work?


I really suggest you set up a test box (even if it's an unused desktop 
- they work great for development machines) and *test* your 
application in the new environment settings.




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



Re: [PHP] Working with overly aggressive anti-spam measures [SOLVED]

2006-10-11 Thread Google Kreme

On 10 Oct 2006, at 19:57 , Dave M G wrote:
It took me a little while to realize that the Spamassassin always  
says that an email is possible scam if it has any score above zero,  
but it takes a score of 5.0 to actually be deleted as spam.


No no no, this is not at all true.

First off, Spamassassin does not delete mail. It, in point of fact,  
CANNOT delete mail as it has no mechanism to do so.


Anyone who is automatically deleting mail on their own with a score  
of 5.0 or higher _will_ miss some legitimate email.  Not might,  
WILL.  Even at a score of 10.0 (where I auto-delete my mail) you will  
miss as much as 0.004% legitimate mail, iirc. (so, 4 messages in  
100,000)


most good email will score between -3 and +1 in Spamassassin if  
you've been running it for any length of time.  Your message scored


X-Spam-Status: No, score=-2.4 required=5.0  
tests=BAYES_00,DNS_FROM_RFC_ABUSE,

SPF_PASS autolearn=no version=3.1.0

So, a -2.4 which, last I checked was something like 99.97% likely to  
be ham.


--
Well I've seen the Heart of Darkness/Read the writing on the wall/and  
the voice out in the desert/Was the voice out in the hall


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



Re: [PHP] PHP 5 Hosting

2006-10-11 Thread Kyle
Hello,
I would suggest dreamhost at www.dreamhost.com.
Their prices look a bit hefty at first but there are referral codes all
over the internet and you can end up saving $97.  Their plans have tons
of bandwidth and space and I haven't had any trouble with it.  But I
would suggest them highly, their service is quite impressive.  And if
you don't like the PHP features they let you compile you own!

Good Luck with it!
Kyle

Ed Lazor wrote:
 Anyone ever use A2Hosting.com?  Or better yet, any recommendations on a
 PHP 5 web hosting company that you're happy with - measured in terms of
 quality support, they know what they're doing, and they have good
 prices?  Bonus points for good drive space, bandwidth, and SSH access.
 
 I ran a Google search and came up with several options.  A2Hosting.com
 seems the best so far.  My only reservation is that they offer 24/7
 support through a message service who will page a tech who in turn will
 call you back - seems sketchy and I can imagine trying to talk someone
 into going to the server room at 2am.  I also checked out many of the
 other options, but some of them seemed even more sketchy... like
 VisualWebHosting.com...  you click on their link for a BBB review and it
 brings up another company entirely... and you call their number and all
 the greeting says is Please leave a message... bep... pretty
 scary if you ask me.
 
 Anyway, thanks in advance for any recommendations you have.
 
 -Ed
 
 --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] PHP Mailer and SMTP = SPAM?

2006-10-11 Thread Peter Lauri
[snip]
Unless the email is coming from somebody the recipient knows/trusts,
then you're going to get marked by them as a spammer -- which will
report back to some of the lists marking you as a spammer.
[/snip]

But is it not a problem sending from the SMTP server thedomain.com using
something else then the email [EMAIL PROTECTED] I am planning to send
from an existing email from the domain.

So even that I send from thedomain.com SMTP server I should to set the FROM
and REPLY TO to the person who is referring? Our main idea was to send the
email from the author of the book as it comes from him, but that is maybe
not a great idea?

So I am in the middle of two suggestions:

1. Make sure that the email is in the domain that you are sending from
2. Make sure that the emails is from the referring persons email so it won't
be marked as spam at their point.

This is what I got from Rick. What are you thoughts on this?

[snip]
when you do a dns lookup (from a machine not on the same network) on the
ipnumber of the sending mail server does it show a name? if you do a forward
lookup on that name, does that resolve to the (same) ipnumber? 

the answer to the first part must be yes, and ideally the second will be
yes. if the first is no, then don't bother sending from that machine
until that issue has been dealt with. 

sending html substantially increases the probability that your messages will
be tagged as spam. certain things will increase that probability. 

your point 2. is mostly irrelevant. an smtp server simply needs to be
configured so it is not an open relay. that is generally the default
configuration (of any MTA that's worth using), and is achievable without
smtp auth.
[/snip]

Best regards,
Peter Lauri

www.lauri.se - personal website
www.dwsasia.com - company website

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-11 Thread Stut

Roman Neuhauser wrote:

# [EMAIL PROTECTED] / 2006-10-11 21:28:36 +0100:

Richard Lynch wrote:

On Tue, October 10, 2006 6:14 pm, Chris de Vidal wrote:

I want to create a customer class which fetches its attributes from
a MySQL database.

No, you don't. :-)

This is a classic example of the obvious OOP solution being wildly
inappropriate.
Ok, so I now find myself in the unusual position of disagreeing with the 
Lynchmeister. Why is this wildly inappropriate? IMHO this is what OOP is 
all about.


No, that's what trivial OOP examples applied to the letter where
a different approach is in order are. If you study the GoF book [GoF]
you'll see that the traditional claim objects model physical
entities from real world (and nothing else) is very simplistic
and terribly limiting.

[GoF] http://www.amazon.com/dp/0201633612/


If you paint yourself into this corner you'll find your code
grinding the database to death in the OO-relational impedance
mismatch. The OOP ideal of a single source of data is nice,
unfortunately the real world gets in the way.


I never said anything about physical entities. The OOP methodology has 
nothing to do with physical entities, but it has everything to do with 
entities. The fact that in this example the entity is physical has no 
bearing on it whatsoever. Nobody said anything about limiting OOP 
entities to physical entities.


You can encapsulate everything to do with a customer in an object. This 
ensures that you don't duplicate any code that works on customer data. 
You avoid duplication of code. As a result you can ensure data integrity 
because there is only one route to read and write it.
 
Who talks about duplicating business logic? You just need to have

more than one access point for the data.


If you have more than one access point for the data you end up with a 
more complicated maintenance situation since you may have several places 
that treat the data differently. This is bad m'kay.


When you're talking about something as simple as a customer it's true 
that an OOP approach probably doesn't add much to the equation. However, 
when you're dealing with complex entities which span several tables and 
have data stored in a different format to how it's used (think 
serialize) it makes sense to have a single point where you can get that 
data so that you don't end up duplicating the code needed to extract and 
store it.


If this is not what you think OOP is all about, do please enlighten us 
as to the error of our ways.


Imagine deleting many rows in a table one by one (pseudocode):

snip

instead of taking them with a single DELETE:

snip

Whoa nellie!! This is a question of design, not a question of whether to 
use OOP. For example, in several of the sites I maintain I have classes 
that inherit from a base class called Table. The base class provides a 
lot of the basic methods for working on a table (think ActiveRecord). It 
also has static methods for doing things like updates and deletes based 
on a where clause. The derived classes can override filter methods 
(AfterLoad and BeforeSave) to massage the data after it's loaded and 
before it's saved. They also add any methods needed for acting on that 
particular entity.


I'm the first to admit that OOP is not always the best methadology to 
use - the 'best methadology for all situations' does not exist. However, 
the general feeling people will get towards OOP from this list seems to 
be 'OOP bad, anything else better'. OOP is great as long as you follow 
OOD principles and have a fair amount of common sense. It should not be 
used just because it's there, but it should also not be dismissed.


In fact, in writing that I've just realised that OOP is not the key... 
OOD is. OOD can be applied (with no syntax or compiler assistance) in a 
functional system which will have great benefits, all of which I think 
most people are aware of but, for whatever reason, fail to adequately 
apply - which is where OOP can be useful since it enforces the structure 
and protection through the syntax (PHP4 sucked for this, PHP5 is better).


When you actually think about it, OOP is not a methadology - it's a 
syntax. OOD is the methadology. Ramble... ramble... ramble... over!


-Stut

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