php-general Digest 13 Feb 2007 15:49:49 -0000 Issue 4624

2007-02-13 Thread php-general-digest-help
php-general Digest 13 Feb 2007 15:49:49 - Issue 4624 Topics (messages 248793 through 248807): Re: Filtering _REQUEST.. Why is this bad? 248793 by: Robert Cummings 248794 by: J R 248795 by: Chris Shiflett Re: Iterators 248796 by: Marc Weber static functions

[PHP] Re: Iterators

2007-02-13 Thread Marc Weber
What did I miss here? In case somebody else wants to know. I've found some examples in php sources ( ext/spl/tests/array_009.phpt ) This is the way to accomplish this: $array = array(1, 2 = array(21, 22 = array(221, 222), 23 = array(231)), 3); $dir = new RecursiveIteratorIterator(new

[PHP] static functions and array_map - why not allowed?

2007-02-13 Thread Marc Weber
Why can't I use static functions in array_map? Example: ?php class Dummy { static public function T($a) { echo T called with $a\n; return $a+2; } } function t($a) { echo t called with $a\n; return $a*2; } echo 'invoking Dummy::T works fine : ', Dummy::T(3),\n;

Re: [PHP] static functions and array_map - why not allowed?

2007-02-13 Thread Jochem Maas
Marc Weber wrote: Why can't I use static functions in array_map? Example: ?php class Dummy { static public function T($a) { echo T called with $a\n; return $a+2; } } function t($a) { echo t called with $a\n; return $a*2; } echo 'invoking Dummy::T works

[PHP] Where would you look for documentation about interface RecursiveIterator? RecursiveIteratorAggregate - suggestion

2007-02-13 Thread Marc Weber
http://de.php.net/~helly/php/ext/spl/interfaceRecursiveIterator.html This piece of code ?php $array = array(1, 2 = array(21, 22 = array(221, 222), 23 = array(231)), 3); $dir = new RecursiveIteratorIterator(new ArrayIterator($array)); foreach ($dir as $file) {

[PHP] Array to Object

2007-02-13 Thread Eli
Hi, Having this array: $arr = array( 'my var'='My Value' ); Notice the space in 'my var'. Converted to object: $obj = (object)$arr; How can I access $arr['my var'] in $obj ? -thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:

Re: [PHP] Array to Object

2007-02-13 Thread Marc Weber
On Tue, Feb 13, 2007 at 12:02:10PM +0200, Eli wrote: Hi, Having this array: $arr = array( 'my var'='My Value' ); Notice the space in 'my var'. Converted to object: $obj = (object)$arr; How can I access $arr['my var'] in $obj ? This works but there may be much

[PHP] Re: Array to Object

2007-02-13 Thread Daniel Kullik
Eli wrote: Hi, Having this array: $arr = array( 'my var'='My Value' ); Notice the space in 'my var'. Converted to object: $obj = (object)$arr; How can I access $arr['my var'] in $obj ? -thanks! print $obj-{'my var'}; $obj-{'my var'} = 'My New Value'; print $obj-{'my var'}; --

Re: [PHP] Where would you look for documentation about interface RecursiveIterator? RecursiveIteratorAggregate - suggestion

2007-02-13 Thread Marc Weber
On Tue, Feb 13, 2007 at 11:54:41AM +0100, Marc Weber wrote: I've implemented a simple walk function which seems to be even easier using php. So consider this thread beeing no longer a problem :) Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:

Re: [PHP] Where would you look for documentation about interface RecursiveIterator? RecursiveIteratorAggregate - suggestion

2007-02-13 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-02-13 11:54:41 +0100: http://de.php.net/~helly/php/ext/spl/interfaceRecursiveIterator.html This piece of code ?php $array = array(1, 2 = array(21, 22 = array(221, 222), 23 = array(231)), 3); $dir = new

[PHP] illegal characters

2007-02-13 Thread M.Ozan Hazer
Hi all, I'm getting these errors: [04-Dec-2006 18:21:56] PHP Warning: Unknown: The session id contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown on line 0 [04-Dec-2006 18:21:56] PHP Warning: Unknown: Failed to write session data (files). Please verify that the

Re: [PHP] illegal characters

2007-02-13 Thread Hidayet Dogan
You may check same discussion at http://bugs.php.net/bug.php?id=31184edit=1 On Mon, 4 Dec 2006, M.Ozan Hazer wrote: Hi all, I'm getting these errors: [04-Dec-2006 18:21:56] PHP Warning: Unknown: The session id contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in

[PHP] print() or echo

2007-02-13 Thread Danial Rahmanzadeh
is it true that echo is a bit faster than print()? in general, when we don't need a return value, which one is better to choose? Cheers, Danial Rahmanzadeh

Re: [PHP] print() or echo

2007-02-13 Thread Robert Cummings
On Tue, 2007-02-13 at 19:19 +0330, Danial Rahmanzadeh wrote: is it true that echo is a bit faster than print()? in general, when we don't need a return value, which one is better to choose? Yes, echo is faster than print. I would suggest echo over print since it is shorter and faster :)

Re: [PHP] print() or echo

2007-02-13 Thread tg-php
As referenced in the manual ( http://us2.php.net/manual/en/function.echo.php ), check out this url: http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40 Short story, there is a difference, but the speed difference is negligable. If anyone cares, I prefer echo too. Not sure why. Shorter

[PHP] how do I just escape double quotes within a string?

2007-02-13 Thread blackwater dev
If I use add slashes, it strips everything, I just want to replace all the double quotes with slash double quote but this, of course, throws errors: str_replace(,\,$code); Thanks!

Re: [PHP] print() or echo

2007-02-13 Thread tg-php
negligible.. blarg spelling. :) = = = Original message = = = As referenced in the manual ( http://us2.php.net/manual/en/function.echo.php ), check out this url: http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40 Short story, there is a difference, but the speed difference is

Re: [PHP] round to nearest 500?

2007-02-13 Thread tedd
At 7:57 PM +0100 2/12/07, Marc Weber wrote: On Mon, 12 Feb 2007 18:02:41 +0100, [EMAIL PROTECTED] wrote: Is there an easy way in php to round to the nearest 500? Yeah $rouned = round($val/500) * 500; I've always questioned the round() function. I believe it has a downward bias, am I wrong?

Re: [PHP] how do I just escape double quotes within a string?

2007-02-13 Thread Eric Butera
On 2/13/07, blackwater dev [EMAIL PROTECTED] wrote: If I use add slashes, it strips everything, I just want to replace all the double quotes with slash double quote but this, of course, throws errors: str_replace(,\,$code); Thanks! Try this $string = 'Hello person. How are you?';

Re: [PHP] how do I just escape double quotes within a string?

2007-02-13 Thread tg-php
You could use addslashes(): http://us3.php.net/manual/en/function.addslashes.php Or, the code you mentioned below, could be rewritten like: str_replace(\,\\,$code); or str_replace('','\',$code); And if you're doing it for a MySQL query call, then you want to use mysql-real-escape-string()

Re: [PHP] print() or echo

2007-02-13 Thread Satyam
echo is slightly faster than print and it takes multiple arguments so instead of: echo 'p' . $test . '/p'; you can do echo 'p' , $test , '/p'; which should be faster, and I say 'should' just because as print should be slower because it has to go into the trouble of setting up a return

Re: [PHP] round to nearest 500?

2007-02-13 Thread tg-php
For downward rounding, you'd always want to use floor() and use ceil() for rounding up. round() rounds up on a 5, down on a 4 and below. Example: echo round(141.074, 2); // 141.07 echo round(141.065, 2); // 141.07 I thought round() (or maybe it was a rounding function in another language or

RE: [PHP] round to nearest 500?

2007-02-13 Thread Tim
snip Supposedly this is an accounting trick that ultimatley works out in the end for proper rounding of money values. Yeah works out for who? Bet it doesn't for the guy paying :P -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] round to nearest 500?

2007-02-13 Thread tg-php
hah yeah, always worth a little skepticism, but it seemed to make some kind of sense. If you always round up or always round down, that's obviously not right and you end up losing potentially a lot of money or over-estimating the money involved. Founding up for 5 through 9 and down for 0

[PHP] failed to upload files into directory named bin

2007-02-13 Thread Yeni Setiawan
Dear all, I was just creating two upload pages,both will upload files into directory named bin. ./bin/ -- directory where the files uploaded ./admin/upload.php-- I wrote path as ../bin/ ./userupload.php-- I wrote path as bin/ I was confused because

Re: [PHP] round to nearest 500?

2007-02-13 Thread Jon Anderson
[EMAIL PROTECTED] wrote: hah yeah, always worth a little skepticism, but it seemed to make some kind of sense. If you always round up or always round down, that's obviously not right and you end up losing potentially a lot of money or over-estimating the money involved. Founding up for 5

RE: [PHP] round to nearest 500?

2007-02-13 Thread tg-php
Ok, screw work.. it's snowing out anyway (not that that makes a real difference to doing PHP work inside), curiosity got the better of me. btw.. the banker rounding code here was pulled from the round() manual page. It's not what I read before, but it's the same concept: function

Re: [PHP] round to nearest 500?

2007-02-13 Thread tg-php
Ahh.. good call. http://en.wikipedia.org/wiki/Rounding Apprently it's called banker's rounding or statistician's rounding and is a little more complicated than just looking at the odd/even of the digit being arounded. This is starting to get into some heavy math theory and scary stuff that

Re: [PHP] round to nearest 500?

2007-02-13 Thread Satyam
- Original Message - From: Jon Anderson [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: hah yeah, always worth a little skepticism, but it seemed to make some kind of sense. If you always round up or always round down, that's obviously not right and you end up losing potentially a lot

Re: [PHP] round to nearest 500?

2007-02-13 Thread tg-php
I don't buy zero doesn't count. But again, this is getting into serious math. It should be good enough to say 0-4 = 0, 5-9 = 10, but if you don't keep strict high precision throughout the whole process and round at every step, things are going to be off no matter what. It's just a matter of

RE: [PHP] Redisplay file name on failed upload

2007-02-13 Thread Brad Fuller
Is it possible to assign form[ upldFile ] = C:\somepath\somefile or form[ upldFile ] = $_FILES['userfile']['name'] The value attribute of the input type=file... tag is not able to be altered or pre-populated for obvious security reasons. The script which does the validation is the same one

Re: [PHP] Redisplay file name on failed upload

2007-02-13 Thread Jochem Maas
Miles Thompson wrote: When a file upload fails, not because of a problem with the upload itself, is there anyway of assigning the value captured by input name=upldFile type=file when the form is redisplayed? The failure may not be due to a problem with the file being uploaded, but

Re: [PHP] Redisplay file name on failed upload

2007-02-13 Thread Jochem Maas
Brad Fuller wrote: Is it possible to assign form[ upldFile ] = C:\somepath\somefile or form[ upldFile ] = $_FILES['userfile']['name'] The value attribute of the input type=file... tag is not able to be altered or pre-populated for obvious security reasons. The script which does the

Re: [PHP] Redisplay file name on failed upload

2007-02-13 Thread Miles Thompson
Thanks guys - I guess the staging area is the way we'll go. (This is from gmail, I'm not used to it, so if I included all of the prev msgs, please forgive me.) Thanks - Miles

[PHP] Redisplay file name on failed upload

2007-02-13 Thread Miles Thompson
When a file upload fails, not because of a problem with the upload itself, is there anyway of assigning the value captured by input name=upldFile type=file when the form is redisplayed? The failure may not be due to a problem with the file being uploaded, but because the user failed to

[PHP] How to upload files up to 40MB with a html post form?

2007-02-13 Thread Mauricio Muriel
How can I upload files up to 40MB with a html post form? (without a ftp client) Please, remember 1. My hosting provider has up to 120 seconds apache timeout 2. My hosting provider has up to 10MB to upload files in php.ini Any kind of ideas? Regards Mauricio M.

RE: [PHP] How to upload files up to 40MB with a html post form?

2007-02-13 Thread Jay Blanchard
[snip] 1. My hosting provider has up to 120 seconds apache timeout 2. My hosting provider has up to 10MB to upload files in php.ini Any kind of ideas? [/snip] Get a new provider? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Filtering _REQUEST.. Why is this bad?

2007-02-13 Thread Richard Lynch
On Mon, February 12, 2007 8:41 pm, J R wrote: it is not adviced to do filtering on _REQUEST getting data in general from it actually. It is much better to specify where your data is coming from ( e.g. _POST or _GET). This is because variable _REQUST contains all the data from the cookies,

Re: [PHP] PHP or Bridge (card game)

2007-02-13 Thread Richard Lynch
On Sat, February 10, 2007 3:19 pm, pub wrote: To all PHP experts, Do any of you also know how to play bridge? If yes, which do you think is harder to learn, PHP or bridge? Bridge is way more harder to learn. Especially all those weird bidding conventions with no rationale. -- Some people

[PHP] Getting mysql_query results into an array

2007-02-13 Thread Skip Evans
Hey all, I read on php.net about resources, the type returned from mysql_query(), and was trying locate the best way to get the result set back from a query into an array. Is simply looping through the result set with mysql_fetch_assoc() the common way to do this? As great as PHP is with

Re: [PHP] Getting mysql_query results into an array

2007-02-13 Thread Richard Lynch
On Tue, February 13, 2007 5:34 pm, Skip Evans wrote: I read on php.net about resources, the type returned from mysql_query(), and was trying locate the best way to get the result set back from a query into an array. Is simply looping through the result set with mysql_fetch_assoc() the

Re: [PHP] Filtering _REQUEST.. Why is this bad?

2007-02-13 Thread J R
i agree, no argument there. Data coming from user should always be considered malicious. I'm just pointing out one reason why not use _REQUEST. but there are intance _REQUEST variable can be useful (just be very careful). Regarding _GET and _POST using same name, there are instance this can be

Re: [PHP] Getting mysql_query results into an array

2007-02-13 Thread Skip Evans
Richard Lynch wrote: The most efficient way is Don't do that. :-) Simply loop through the results and do whatever you want to do with them, and don't put them into an array at all. This makes perfect sense. However, I am currently writing an abstraction layer for a project that will later

Re: [PHP] Getting mysql_query results into an array

2007-02-13 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-02-13 17:43:10 -0700: Richard Lynch wrote: The most efficient way is Don't do that. :-) Simply loop through the results and do whatever you want to do with them, and don't put them into an array at all. This makes perfect sense. However, I am currently

Re: [PHP] Getting mysql_query results into an array

2007-02-13 Thread Robert Cummings
On Tue, 2007-02-13 at 18:22 -0600, Richard Lynch wrote: #2 loop through mysql result set to build $array perform some kind of calculation upon $array In this case, it's USUALLY much more efficient to write an SQL query to perform the calculation. Databases are highly optimized for this