RE: [PHP] Re: PHP in HTML code
> -Original Message- > From: Bob McConnell [mailto:r...@cbord.com] > Sent: 15 March 2010 18:13 > > From: Jochem Maas > > > Op 3/13/10 3:49 PM, Jorge Gomes schreef: > >> First of all, i recommend the use of normal php tags ( ?>) > because > >> the short tags are atm marked as* **DEPRECATED*. > > > > that's a documentation error. > > No it's not. The short tags conflict with both XML and XHTML and > therefore are being phased out. Jochem is right, Bob and Jorge are wrong. Proof: http://marc.info/?l=php-internals&m=126832992915664&w=2 Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: PHP in HTML code
On Tue, 2010-03-16 at 11:16 +, Ford, Mike wrote: > > -Original Message- > > From: Bob McConnell [mailto:r...@cbord.com] > > Sent: 15 March 2010 18:13 > > > > From: Jochem Maas > > > > > Op 3/13/10 3:49 PM, Jorge Gomes schreef: > > >> First of all, i recommend the use of normal php tags ( > ?>) > > because > > >> the short tags are atm marked as* **DEPRECATED*. > > > > > > that's a documentation error. > > > > No it's not. The short tags conflict with both XML and XHTML and > > therefore are being phased out. > > Jochem is right, Bob and Jorge are wrong. > > Proof: http://marc.info/?l=php-internals&m=126832992915664&w=2 > > Cheers! > > Mike > -- > Mike Ford, > Electronic Information Developer, Libraries and Learning Innovation, > Leeds Metropolitan University, C507, Civic Quarter Campus, > Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom > Email: m.f...@leedsmet.ac.uk > Tel: +44 113 812 4730 > > > > > > To view the terms under which this email is distributed, please go to > http://disclaimer.leedsmet.ac.uk/email.htm > That's not really proof of anything, it's just an archived email from this list... Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] Re: PHP in HTML code
> -Original Message- > From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] > Sent: 16 March 2010 11:16 > > On Tue, 2010-03-16 at 11:16 +, Ford, Mike wrote: > > > > > Proof: http://marc.info/?l=php-internals&m=126832992915664&w=2 > > > > That's not really proof of anything, it's just an archived email > from this list... Well, firstly it's an archived email from the *internals* (i.e. PHP developers) list, not this one. And secondly it's from someone whom I trust to know what he's talking about. If I looked, I'm sure I could dig up several similarly definitive (but less recent) pronouncements from PHP "names", including Rasmus himself. In fact: http://marc.info/?l=php-internals&m=123969574312781&w=2 Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
[PHP] Spreadsheet_Excel_Reader problem
i have a problem of reading values from excel file via spreadsheet_excel_reader which is a php class used to manipulate excel files. $data = new Spreadsheet_Excel_Reader(); $data->setOutputEncoding('CP936'); $data->read("d:\\tmp.xls"); $rows=$data->sheets[0]['numRows']; $cell = $data->sheets[0]['cells'][1][1]; if i type many rows,say 1000, in the tmp.xls, it can read, $rows shows 1000, however, 1000 rows of data are copied from another excel file and these cells may have different background or other changes that differ from normal cells, it fails to read.the variable $rows shows nothingwhat i can do now is to split these data into small groups, small enough to be read, it really takes plenty of time. i dont know why, has somebody met this problem ever?
Re: [PHP] php-cli
On 15 March 2010 00:27, Rick Pasotto wrote: > On Sun, Mar 14, 2010 at 08:40:51PM +, Ashley Sheridan wrote: >> On Sun, 2010-03-14 at 16:41 -0400, Rick Pasotto wrote: >> >> > On Sun, Mar 14, 2010 at 06:13:24PM +, Ashley Sheridan wrote: >> > > On Sun, 2010-03-14 at 14:15 -0400, Rick Pasotto wrote: >> > > >> > > > Has cli php changed recently? >> > > > >> > > > I've got a php script (script1) that creates a php script (script2) by >> > > > opening a file and then writing to it. When I try to run it from the >> > > > command line script1 is simply copied to stdout. When I run it from the >> > > > browser it works as expected. The directory has 777 permissions so that >> > > > should not be the problem. >> > > > >> > > > Any ideas? >> > > >> > > How are you running it from the command line? >> > >> > Is there more than one way? I suppose with and without the -f could >> > count as two ways, but the man page says without defaults to with so >> > they're really the same. >> >> Well you havn't given an example, and just say you're calling the script >> from command line and it's outputting the script there. Are you maybe >> just calling the php file without calling php first? > > Of course not. php scripts are not executable. If I had tried to execute > it directly the shell would have told me that. If I had then set the > executable bit the shell would have tried to execute the contents of the > file and the shell would have given several error messages. > > I repeat: is there more than one way to run a php script from the cli? > > -- > "Feeling sorry for yourself, and you present condition, is not only a > waste of energy but the worst habit you could possibly have." > -- Dale Carnegie > Rick Pasotto r...@niof.net http://www.niof.net > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Be careful. .BAT files are not executable, but you don't need to put the command line processor in front do you? You can quite easily turn ... C:\PHP5\PHP.exe -f C:\Pathed\Directory\Script.php -- -script_arg1 -script_arg2 into Script -script_arg1 -script_arg2 No php.exe, no .php, no -f See http://docs.php.net/manual/en/install.windows.commandline.php You can even turn php scripts into filters ... Script -script_arg1 -script_arg2 | Script2 -script_arg1 -script_arg2 sort of thing. -- - Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Spreadsheet_Excel_Reader problem
On Tue, 2010-03-16 at 20:16 +0800, I am on the top of the world! Borlange University wrote: > i have a problem of reading values from excel file via > spreadsheet_excel_reader which is a php class used to manipulate excel > files. > > $data = new Spreadsheet_Excel_Reader(); > $data->setOutputEncoding('CP936'); > $data->read("d:\\tmp.xls"); > $rows=$data->sheets[0]['numRows']; > $cell = $data->sheets[0]['cells'][1][1]; > > if i type many rows,say 1000, in the tmp.xls, it can read, $rows shows 1000, > however, 1000 rows of data are copied from another excel file and these > cells may have different background or other changes that differ from normal > cells, it fails to read.the variable $rows shows nothingwhat i can do > now is to split these data into small groups, small enough to be read, it > really takes plenty of time. > > > i dont know why, has somebody met this problem ever? If it's just the data you need, try using a csv file instead. The Excel format is closed, and as such, the PHP classes won't have full support for all of it's features. It seems like formatting is causing the data to be written to the spreadsheet differently maybe. Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] Re: PHP in HTML code
From: Ford, Mike > From: Ashley Sheridan >> On Tue, 2010-03-16 at 11:16 +, Ford, Mike wrote: >> > >> > >> Proof: http://marc.info/?l=php-internals&m=126832992915664&w=2 > >> >> >> That's not really proof of anything, it's just an archived email >> from this list... > > Well, firstly it's an archived email from the *internals* (i.e. > PHP developers) list, not this one. And secondly it's from > someone whom I trust to know what he's talking about. If I > looked, I'm sure I could dig up several similarly definitive > (but less recent) pronouncements from PHP "names", including > Rasmus himself. > > In fact: http://marc.info/?l=php-internals&m=123969574312781&w=2 Well, that's their prerogative, but I believe they are wrong. Short tags cause more problems than they will ever solve, and should be removed from the language ASAP. I would classify that as a design flaw. In the meantime, since we are upgrading our pages to XHTML, we are replacing the short tags wherever they occur. Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need routine to tell me number of dimensions in array.
On 15 March 2010 23:45, Daevid Vincent wrote: > Anyone have a function that will return an integer of the number of > dimensions an array has? /** * Get the maximum depth of an array * * @param array &$Data A reference to the data array * @return int The maximum number of levels in the array. */ function arrayGetDepth(array &$Data) { static $CurrentDepth = 1; static $MaxDepth = 1; array_walk($Data, function($Value, $Key) use(&$CurrentDepth, &$MaxDepth) { if (is_array($Value)) { $MaxDepth = max($MaxDepth, ++$CurrentDepth); arrayGetDepth($Value); --$CurrentDepth; } }); return $MaxDepth; } Extending Jim and Roberts comments to this. No globals. By using a reference to the array, large arrays are not copied (memory footprint is smaller). And by using array_walk, a separate internal pointer is used, so no need to worry about losing your position on the array. Something to watch out for though is recursion in the array. If a value in the array is a reference to another part of the array, you are going to loop around for ever. $Data = array(&$Data); for example, with the line ... echo "$CurrentDepth, $MaxDepth, $Key\n"; in the callback function() will report 17701 before crashing out (no stack error surprisingly enough). Regards, Richard Quadling. -- - Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Spreadsheet_Excel_Reader problem
Or maybe you want to check out this: http://www.codeplex.com/PHPExcel I havn't checked it out for your special purpose but i found it useful for some other jobs (especially excell 2007 support). regards Jochen Ashley Sheridan schrieb: On Tue, 2010-03-16 at 20:16 +0800, I am on the top of the world! Borlange University wrote: i have a problem of reading values from excel file via spreadsheet_excel_reader which is a php class used to manipulate excel files. $data = new Spreadsheet_Excel_Reader(); $data->setOutputEncoding('CP936'); $data->read("d:\\tmp.xls"); $rows=$data->sheets[0]['numRows']; $cell = $data->sheets[0]['cells'][1][1]; if i type many rows,say 1000, in the tmp.xls, it can read, $rows shows 1000, however, 1000 rows of data are copied from another excel file and these cells may have different background or other changes that differ from normal cells, it fails to read.the variable $rows shows nothingwhat i can do now is to split these data into small groups, small enough to be read, it really takes plenty of time. i dont know why, has somebody met this problem ever? If it's just the data you need, try using a csv file instead. The Excel format is closed, and as such, the PHP classes won't have full support for all of it's features. It seems like formatting is causing the data to be written to the spreadsheet differently maybe. Thanks, Ash http://www.ashleysheridan.co.uk -- Sport Import GmbH - Amtsgericht Oldenburg - Tel: +49-4405-9280-63 Industriestrasse 39 - HRB 1202900- 26188 Edewecht - GF: Michael Müllmann -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] $_FILE array being truncated
p.general, I have a form with 75 or so file input controls: Usually when I submit the form, I only upload two or so files. So in the post request, it sends the two files along with the other blank 73 fields. This has been working fine on my live and test servers so far. However as of the past few days only the first 20 file fields are recieved on the live server. I saw this by dumping the $_FILES array. This does not happen on the test server. I can see all 75 file fields been sent across in the POST header in wireshark, but but only the first 20 appear in the $_FILES array. Has anyone come across this problem of the $_FILE array being truncated? I don't recall changing anything on the live server. Richard -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need routine to tell me number of dimensions in array.
Richard Quadling wrote: On 15 March 2010 23:45, Daevid Vincent wrote: Anyone have a function that will return an integer of the number of dimensions an array has? /** * Get the maximum depth of an array * * @param array &$Data A reference to the data array * @return int The maximum number of levels in the array. */ function arrayGetDepth(array &$Data) { static $CurrentDepth = 1; static $MaxDepth = 1; array_walk($Data, function($Value, $Key) use(&$CurrentDepth, &$MaxDepth) { if (is_array($Value)) { $MaxDepth = max($MaxDepth, ++$CurrentDepth); arrayGetDepth($Value); --$CurrentDepth; } }); return $MaxDepth; } Extending Jim and Roberts comments to this. No globals. By using a reference to the array, large arrays are not copied (memory footprint is smaller). Using a reference actually increases overhead. References in PHP were mostly useful in PHP4 when assigning objects would cause the object to be copied. But even then, for arrays, a Copy on Write (COW) strategy was used (and is still used) such that you don't copy any values. Try it for yourself: Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need routine to tell me number of dimensions in array.
This is one example where references actually decrease memory usage. The main reason is the recursive nature of the function. Try wrote: > > > Richard Quadling wrote: >> >> On 15 March 2010 23:45, Daevid Vincent wrote: >>> >>> Anyone have a function that will return an integer of the number of >>> dimensions an array has? >> >> /** >> * Get the maximum depth of an array >> * >> * @param array &$Data A reference to the data array >> * @return int The maximum number of levels in the array. >> */ >> function arrayGetDepth(array &$Data) { >> static $CurrentDepth = 1; >> static $MaxDepth = 1; >> >> array_walk($Data, function($Value, $Key) use(&$CurrentDepth, >> &$MaxDepth) { >> if (is_array($Value)) { >> $MaxDepth = max($MaxDepth, ++$CurrentDepth); >> arrayGetDepth($Value); >> --$CurrentDepth; >> } >> }); >> >> return $MaxDepth; >> } >> >> Extending Jim and Roberts comments to this. No globals. By using a >> reference to the array, large arrays are not copied (memory footprint >> is smaller). > > Using a reference actually increases overhead. References in PHP were mostly > useful in PHP4 when assigning objects would cause the object to be copied. > But even then, for arrays, a Copy on Write (COW) strategy was used (and is > still used) such that you don't copy any values. Try it for yourself: > > > $copies = array(); > $string = str_repeat( '*', 100 ); > > echo memory_get_usage()."\n"; > for( $i = 0; $i < 1000; $i++ ) > { > $copies[] = $string; > } > echo memory_get_usage()."\n"; > > ?> > > Cheers, > Rob. > -- > http://www.interjinn.com > Application and Templating Framework for PHP > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- WWW: http://plphp.dk / http://plind.dk LinkedIn: http://www.linkedin.com/in/plind Flickr: http://www.flickr.com/photos/fake51 BeWelcome: Fake51 Couchsurfing: Fake51 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Deleting multiple backslashes; regex?
On 3/15/2010 5:03 PM, Jim Lucas wrote: Al wrote: Anyone have a regex pattern for deleting multiple backslashes e.g., \\\ I pretty good with regex; but, be damned if I can delete them with preg_replace() I've tried "" as the manual says preg_replace("//", '', $str); preg_replace("/()+/", '', $str); preg_replace("/\x5C/", '', $str); preg_replace("/\\x5c/", '', $str); And lots of others. stripslashes() and stripcslashes() are limited. Might I ask, how are the multiple slashes getting generated in the first place? Where is the data coming from? Next question would be: Do you want to completely remove all instances of multiple backslashes? Or, do you want to replace all instances of multiple backslashes with a single backslash? I would try something like this: done! As I reported earlier, problem was my code was reloading a POST array following the backlash removal. Dumb error on my part. Re: "Might I ask, how are the multiple slashes getting generated in the first place? Where is the data coming from?" It comes from a client-side editor where users can enter them at will. It is my standard practice to do a good job of protecting users from themselves. I originally just had the usual stripslashes() but found it didn't take care of users adding several. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP MySQL Insert Statements
2010/3/12 Martine Osias > Hi, > > My insert statements on this web page don't execute. The select statements > do work. This tells me that the database connection is working. The username > and password are the administrator's. What else could prevent the insert > statements from executing? > > The assigned permissions to that account. Using MySQL, you can define *who* is allowed to do *what*. (i.e. SELECT, INSERT, GRANT) (or syntax errors in your insert statements, like others said before.) Regards
Re: [PHP] PHP MySQL Insert Statements
Always make sure your dynamic sql string in php code are as expected var_dump($sql) before query On Thu, Mar 11, 2010 at 10:13 PM, Martine Osias wrote: > Hi, > > My insert statements on this web page don't execute. The select statements > do work. This tells me that the database connection is working. The username > and password are the administrator's. What else could prevent the insert > statements from executing? > > Thank you. > > > Martine > > -- > 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] Need routine to tell me number of dimensions in array.
Peter Lind wrote: This is one example where references actually decrease memory usage. The main reason is the recursive nature of the function. Try Doh, forgot about that :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need routine to tell me number of dimensions in array.
Peter Lind wrote: This is one example where references actually decrease memory usage. The main reason is the recursive nature of the function. Try BTW, it's not the recursive nature of the function causing the problem. It's the movement of the internal pointer within the array. When it moves the COW realizes the copy's pointer has moved and splits off the copy. You can verify this by echoing the memory usage when you first enter carray(). The spike occurs inside the foreach loop. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need routine to tell me number of dimensions in array.
Hmm, will probably have to look inside PHP for this ... the foreach loop will copy each element as it loops over it (without actually copying, obviously), however there's no change happening to the element at any point and so there's nothing to suggest to the copy-on-write to create a new instance of the sub-array. It should look like this: $a = array(0, 1, 2, array(0, 1, 2, 3), 4, 5, 6, n); $b = $a[3]; doStuffs($b); Whether or not you loop over $a and thus move the internal pointer, you don't change (well, shouldn't, anyway) $b as that's a subarray which has it's own internal pointer, that isn't touched. Or maybe I've gotten this completely backwards ... Regards Peter On 16 March 2010 17:12, Robert Cummings wrote: > Peter Lind wrote: >> >> This is one example where references actually decrease memory usage. >> The main reason is the recursive nature of the function. Try > > BTW, it's not the recursive nature of the function causing the problem. It's > the movement of the internal pointer within the array. When it moves the COW > realizes the copy's pointer has moved and splits off the copy. You can > verify this by echoing the memory usage when you first enter carray(). The > spike occurs inside the foreach loop. > > Cheers, > Rob. > -- > http://www.interjinn.com > Application and Templating Framework for PHP > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- WWW: http://plphp.dk / http://plind.dk LinkedIn: http://www.linkedin.com/in/plind Flickr: http://www.flickr.com/photos/fake51 BeWelcome: Fake51 Couchsurfing: Fake51 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need routine to tell me number of dimensions in array.
Peter Lind wrote: Hmm, will probably have to look inside PHP for this ... the foreach loop will copy each element as it loops over it (without actually copying, obviously), however there's no change happening to the element at any point and so there's nothing to suggest to the copy-on-write to create a new instance of the sub-array. It should look like this: $a = array(0, 1, 2, array(0, 1, 2, 3), 4, 5, 6, n); $b = $a[3]; doStuffs($b); Whether or not you loop over $a and thus move the internal pointer, you don't change (well, shouldn't, anyway) $b as that's a subarray which has it's own internal pointer, that isn't touched. Or maybe I've gotten this completely backwards ... I'm not sure of the exact reason... PHP has the following comment: Note: Unless the array is referenced, foreach operates on a copy of the specified array and not the array itself. foreach has some side effects on the array pointer. Don't rely on the array pointer during or after the foreach without resetting it. http://php.net/manual/en/control-structures.foreach.php I've always found the foreach loop to a be a bit on the bizarre size, this is probably just another one of those bizarrities :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_FILE array being truncated
On Tue, Mar 16, 2010 at 15:19, Richard H Lee wrote: > p.general, > > I have a form with 75 or so file input controls: > Usually when I submit the form, I only upload two or so files. So in the > post request, it sends the two files along with the other blank 73 fields. > This has been working fine on my live and test servers so far. > > However as of the past few days only the first 20 file fields are recieved > on the live server. I saw this by dumping the $_FILES array. This does not > happen on the test server. I can see all 75 file fields been sent across in > the POST header in wireshark, but but only the first 20 appear in the > $_FILES array. > > Has anyone come across this problem of the $_FILE array being truncated? I > don't recall changing anything on the live server. > > Richard Check out max_file_uploads which was added in PHP 5.2.12 and defaults to 20. -- Daniel Egeberg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_FILE array being truncated
On Tue, 2010-03-16 at 18:25 +0100, Daniel Egeberg wrote: > On Tue, Mar 16, 2010 at 15:19, Richard H Lee wrote: > > p.general, > > > > I have a form with 75 or so file input controls: > > > Usually when I submit the form, I only upload two or so files. So in the > > post request, it sends the two files along with the other blank 73 fields. > > This has been working fine on my live and test servers so far. > > > > However as of the past few days only the first 20 file fields are recieved > > on the live server. I saw this by dumping the $_FILES array. This does not > > happen on the test server. I can see all 75 file fields been sent across in > > the POST header in wireshark, but but only the first 20 appear in the > > $_FILES array. > > > > Has anyone come across this problem of the $_FILE array being truncated? I > > don't recall changing anything on the live server. > > > > Richard > > Check out max_file_uploads which was added in PHP 5.2.12 and defaults to 20. > > -- > Daniel Egeberg > I really wouldn't rely on a form that contains more than 20 file upload boxes though. If someone uploads some large files, they're stuck with an extremely long wait which will slow down your server a bit as well if a lot of people are using the same form at the same time. Have you looked at using a multi-file upload element instead? Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] $_FILE array being truncated
> Check out max_file_uploads which was added in PHP 5.2.12 and defaults to > 20. Yes that was the problem, I set max_file_uploads higher and it works now. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] best way to set up an include path for a multi-level project?
i have a project (let's call it "proj") which lives in the "proj" directory and which contains several subdirs, some of which might contain their own subdirs and so on. some of those subdirs might contain utility classes that i want to include or require elsewhere, so i want to be able to just: require 'util.php'; and have the PHP include path "do the right thing." right now, it's ugly, as in, having PHP files that do: require '../../proj/util.php'; meaning every single file that wants to include another proj-related file has to know its relative position in the proj hierarchy. barf. based on my experience with shell and makefile-based projects, my preference would be that anyone who checks out a copy of the project can check it out anywhere they want, then they need to set the single shell environment variable, say PROJ_DIR, to the top-level directory location, say: $ export PROJ_DIR=/home/rpjday/php/things/proj i would then make sure that env vars are available to PHP scripts via /etc/php.ini: variables_order = "EGPCS" ^ and all PHP scripts would start off with something like: set_include_path(get_include_path() . PATH_SEPARATOR . getenv('PROJ_DIR')); at that point (and correct me if i'm wrong), all subsequent includes or requires would simply need to reflect the location of the file relative to its PROJ_DIR location (barring any weird conflicts with system files having the same name, of course). does that sound about right? is there a standard way to do this? that is, to have a sizable PHP hierarchy and allow any files within that hierarchy to include others conveniently without having to hardcode directory names. requiring users to simply set a single env var has always worked for me. is that what others do to solve this? thanks. rday -- Robert P. J. Day Waterloo, Ontario, CANADA Linux Consulting, Training and Kernel Pedantry. Web page: http://crashcourse.ca Twitter: http://twitter.com/rpjday -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP in HTML code
At 5:54 PM + 3/15/10, Jochem Maas wrote: Op 3/13/10 3:49 PM, Jorge Gomes schreef: First of all, i recommend the use of normal php tags () because the short tags are atm marked as* **DEPRECATED*. that's a documentation error. You should also echo your values to the page, instead using the shortcut it's not lazy, it's succinct and much easier to read (once you know what it means), Yes, but like all web languages, they don't live in a vacuum -- they must play well with others to survive. Programming is dynamic not static. While using "others" and therein lies the problem. If XML (and possibility others) don't accept the short term tag, then why use it? Using "Standards" like this help promote better communication between all languages -- what's wrong with that? Simply put, either communicate better or don't -- that's your choice -- but your decision is also a demonstration to your client/employer/peers as to your desire to produce the "best" possible code. I look at code containing "tables and embedded styling for presentation -- "This must be old code OR the programmer still doesn't get it". Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_FILE array being truncated
Ashley Sheridan wrote on 16/03/2010 18:28: I really wouldn't rely on a form that contains more than 20 file upload boxes though. If someone uploads some large files, they're stuck with an extremely long wait which will slow down your server a bit as well if a lot of people are using the same form at the same time. True. Instead make the upload with AJAX, so the file starts uploading when the field is changed (onChange()) or out of focus (is there such a function? onUnFocus()? :-)). See gmail attachment for an example. -- Kind regards Kim Emax - masterminds.dk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] best way to set up an include path for a multi-level project?
On 03/16/2010 06:57 PM, Robert P. J. Day wrote: i have a project (let's call it "proj") which lives in the "proj" directory and which contains several subdirs, some of which might contain their own subdirs and so on. some of those subdirs might contain utility classes that i want to include or require elsewhere, so i want to be able to just: require 'util.php'; and have the PHP include path "do the right thing." right now, it's ugly, as in, having PHP files that do: require '../../proj/util.php'; meaning every single file that wants to include another proj-related file has to know its relative position in the proj hierarchy. barf. I used to use auto detecting absolute paths but switched to relative paths when a client decided to switch his hosting company, I *think* it was GoDaddy. They required relative paths when using the shared SSL server or the browser would throw errors. It is really not bad as long a you keep your directory structure consistent. I have never received a bug report because of an include path issue. It also does not matter where the root directory of the app is located since everything is relative anyway. There is also no need for the user to configure anything because of the relative paths. So I just set $include = './include/abc/def/' at the top of the executing php page and use it further down. You make $include a global or simply pass $include to functions or classes when they need to include files. I use the later approach. As I said I never had a problem with it, it just requires consistency. -- John Eine der erstaunlichsten Erscheinungen ist, daß man sich einbildet, von abhängigen Menschen unabhängige Meinungen erwarten zu dürfen. [Sigmund Graff] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] best way to set up an include path for a multi-level project?
On 03/16/2010 08:50 PM, John Black wrote: So I just set $include = './include/abc/def/' at the top of the correction, I set $include to the relative path of the include directory and then use it like this: $include = '../../include/'; require $include.'abc/file1.php'; require_once $include.'abc/def/file2.php'; require_once $include.'file3.php'; Still works the same way but since all my include files are in include or some sub directory of it this works perfect. -- John Vorurteil ist das Kind von Ignoranz. [William Hazlitt] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] best way to set up an include path for a multi-level project?
On Tue, Mar 16, 2010 at 1:57 PM, Robert P. J. Day wrote: > > and all PHP scripts would start off with something like: > > set_include_path(get_include_path() . PATH_SEPARATOR . getenv('PROJ_DIR')); > just utilize include_path directive in php.ini -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_FILE array being truncated
jumploader.com might be interesting to you.. On Tue, Mar 16, 2010 at 3:19 PM, Richard H Lee wrote: > p.general, > > I have a form with 75 or so file input controls: > Usually when I submit the form, I only upload two or so files. So in the > post request, it sends the two files along with the other blank 73 fields. > This has been working fine on my live and test servers so far. > > However as of the past few days only the first 20 file fields are recieved > on the live server. I saw this by dumping the $_FILES array. This does not > happen on the test server. I can see all 75 file fields been sent across in > the POST header in wireshark, but but only the first 20 appear in the > $_FILES array. > > Has anyone come across this problem of the $_FILE array being truncated? I > don't recall changing anything on the live server. > > Richard > > -- > 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] Need routine to tell me number of dimensions in array.
maybe you should be foreach()ing with references? php.net : search "foreach" : As of PHP 5, you can easily modify array's elements by preceding $value with &. This will assign reference instead of copying the value. This is possible only if iterated array can be referenced (i.e. is variable), On Tue, Mar 16, 2010 at 5:43 PM, Robert Cummings wrote: > Peter Lind wrote: >> >> Hmm, will probably have to look inside PHP for this ... the foreach >> loop will copy each element as it loops over it (without actually >> copying, obviously), however there's no change happening to the >> element at any point and so there's nothing to suggest to the >> copy-on-write to create a new instance of the sub-array. >> >> It should look like this: >> $a = array(0, 1, 2, array(0, 1, 2, 3), 4, 5, 6, n); >> $b = $a[3]; >> doStuffs($b); >> >> Whether or not you loop over $a and thus move the internal pointer, >> you don't change (well, shouldn't, anyway) $b as that's a subarray >> which has it's own internal pointer, that isn't touched. >> >> Or maybe I've gotten this completely backwards ... > > I'm not sure of the exact reason... PHP has the following comment: > > Note: Unless the array is referenced, foreach operates on a copy > of the specified array and not the array itself. foreach > has some side effects on the array pointer. Don't rely on > the array pointer during or after the foreach without > resetting it. > > http://php.net/manual/en/control-structures.foreach.php > > I've always found the foreach loop to a be a bit on the bizarre size, this > is probably just another one of those bizarrities :) > > Cheers, > Rob. > -- > http://www.interjinn.com > Application and Templating Framework for PHP > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] best way to set up an include path for a multi-level project?
On Tue, Mar 16, 2010 at 9:48 PM, Ryan Sun wrote: > just utilize include_path directive in php.ini yea, or via ini_set('include_path', ); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP in HTML code
maybe adding a wrote: > At 5:54 PM + 3/15/10, Jochem Maas wrote: >> >> Op 3/13/10 3:49 PM, Jorge Gomes schreef: >>> >>> First of all, i recommend the use of normal php tags () >>> because >>> the short tags are atm marked as* **DEPRECATED*. >> >> that's a documentation error. >> >>> >>> You should also echo your values to the page, instead using the shortcut >>> >> (stop being a lazy ass! :P): >> >> it's not lazy, it's succinct and much easier to read (once you know what >> it means), > > Yes, but like all web languages, they don't live in a vacuum -- they must > play well with others to survive. Programming is dynamic not static. > > While using " and therein lies the problem. If XML (and possibility others) don't accept > the short term tag, then why use it? > > Using "Standards" like this help promote better communication between all > languages -- what's wrong with that? Simply put, either communicate better > or don't -- that's your choice -- but your decision is also a demonstration > to your client/employer/peers as to your desire to produce the "best" > possible code. > > I look at code containing " and embedded styling for presentation -- "This must be old code OR the > programmer still doesn't get it". > > Cheers, > > tedd > > -- > --- > http://sperling.com http://ancientstones.com http://earthstones.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP in HTML code
On Tue, 2010-03-16 at 23:42 +0100, Rene Veerman wrote: > maybe adding a then deprecating > On Tue, Mar 16, 2010 at 7:18 PM, tedd wrote: > > At 5:54 PM + 3/15/10, Jochem Maas wrote: > >> > >> Op 3/13/10 3:49 PM, Jorge Gomes schreef: > >>> > >>> First of all, i recommend the use of normal php tags () > >>> because > >>> the short tags are atm marked as* **DEPRECATED*. > >> > >> that's a documentation error. > >> > >>> > >>> You should also echo your values to the page, instead using the shortcut > >>> >>> (stop being a lazy ass! :P): > >> > >> it's not lazy, it's succinct and much easier to read (once you know what > >> it means), > > > > Yes, but like all web languages, they don't live in a vacuum -- they must > > play well with others to survive. Programming is dynamic not static. > > > > While using " > and therein lies the problem. If XML (and possibility others) don't accept > > the short term tag, then why use it? > > > > Using "Standards" like this help promote better communication between all > > languages -- what's wrong with that? Simply put, either communicate better > > or don't -- that's your choice -- but your decision is also a demonstration > > to your client/employer/peers as to your desire to produce the "best" > > possible code. > > > > I look at code containing " > and embedded styling for presentation -- "This must be old code OR the > > programmer still doesn't get it". > > > > Cheers, > > > > tedd > > > > -- > > --- > > http://sperling.com http://ancientstones.com http://earthstones.com > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > I think that would just add to an already confusing situation. Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] Database vs. Array
I have a script that connects to an external database to process about 4,000 records. Each record needs to be operated on pretty heavily, and the script overall takes about half an hour to execute. We've hit a wall where the script's memory usage exceeds the amount allocated to PHP. I've increased the allotted memory to 32MB, but that's not ideal for our purposes. So my thought is, would it be more efficient, memory-wise, to read the database entries into an array and process the array records, rather than maintain the database connection for the entire run of the script. This is not an issue I've come across before, so any thoughts would be much appreciated. Thanks in advance. -- Richard S. Crawford (rich...@underpope.com) http://www.underpope.com Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com)
Re: [PHP] Database vs. Array
What I usually do is to pull a limited set of records ( like 10 or 50 ) and the do the operations on them, update a column in that table to mark them completed and use JavaScript to reload the page and pull the next set out where that flag field is null. No memory issue, no need to large timeouts and it's self recovering. Bastien On Tuesday, March 16, 2010, Richard S. Crawford wrote: > I have a script that connects to an external database to process about 4,000 > records. Each record needs to be operated on pretty heavily, and the script > overall takes about half an hour to execute. We've hit a wall where the > script's memory usage exceeds the amount allocated to PHP. I've increased > the allotted memory to 32MB, but that's not ideal for our purposes. > > So my thought is, would it be more efficient, memory-wise, to read the > database entries into an array and process the array records, rather than > maintain the database connection for the entire run of the script. This is > not an issue I've come across before, so any thoughts would be much > appreciated. > > Thanks in advance. > > -- > Richard S. Crawford (rich...@underpope.com) > http://www.underpope.com > Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com) > -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Database vs. Array
Maybe you want to optimize your script first, and I don't think read entire data set into array would save you much time. Don't create new variables when its unnecessary, cache data when its necessary, try memcached, and I think heavy php cli scripts are always likely to resume a lot of resource, I think GC of php is not so reliable... or maybe I don't know how to use it. On 3/16/2010 7:13 PM, Richard S. Crawford wrote: I have a script that connects to an external database to process about 4,000 records. Each record needs to be operated on pretty heavily, and the script overall takes about half an hour to execute. We've hit a wall where the script's memory usage exceeds the amount allocated to PHP. I've increased the allotted memory to 32MB, but that's not ideal for our purposes. So my thought is, would it be more efficient, memory-wise, to read the database entries into an array and process the array records, rather than maintain the database connection for the entire run of the script. This is not an issue I've come across before, so any thoughts would be much appreciated. Thanks in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP in HTML code
On Tue, Mar 16, 2010 at 7:06 PM, Ashley Sheridan wrote: > On Tue, 2010-03-16 at 23:42 +0100, Rene Veerman wrote: > > > maybe adding a > then deprecating > > > On Tue, Mar 16, 2010 at 7:18 PM, tedd wrote: > > > At 5:54 PM + 3/15/10, Jochem Maas wrote: > > >> > > >> Op 3/13/10 3:49 PM, Jorge Gomes schreef: > > >>> > > >>> First of all, i recommend the use of normal php tags () > > >>> because > > >>> the short tags are atm marked as* **DEPRECATED*. > > >> > > >> that's a documentation error. > > >> > > >>> > > >>> You should also echo your values to the page, instead using the > shortcut > > >>> > >>> (stop being a lazy ass! :P): > > >> > > >> it's not lazy, it's succinct and much easier to read (once you know > what > > >> it means), > > > > > > Yes, but like all web languages, they don't live in a vacuum -- they > must > > > play well with others to survive. Programming is dynamic not static. > > > > > > While using " others" > > > and therein lies the problem. If XML (and possibility others) don't > accept > > > the short term tag, then why use it? > > > > > > Using "Standards" like this help promote better communication between > all > > > languages -- what's wrong with that? Simply put, either communicate > better > > > or don't -- that's your choice -- but your decision is also a > demonstration > > > to your client/employer/peers as to your desire to produce the "best" > > > possible code. > > > > > > I look at code containing " tables > > > and embedded styling for presentation -- "This must be old code OR the > > > programmer still doesn't get it". > > > > > > Cheers, > > > > > > tedd > > > > > > -- > > > --- > > > http://sperling.com http://ancientstones.com http://earthstones.com > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > I think that would just add to an already confusing situation. > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > > I'll confess that I work on ASP.Net just as much as PHP (If you must throw tomatoes, make sure their really ripe so they don't hurt as much ;) I appreciate the different tags offered in ASP.Net, as they succinctly provide some convenient capabilities (one version provides similar capabilites to PHP's .) I believe that although they're removing the ASP version of tags (e.g., <% %>) from PHP 6, they're keeping the short tag option debated in this thread, and I hope they do. To say that using short tags is bad form seems quite strong. Additionally, saying that XML doesn't accept the syntax is also extreme. It's not that XML doesn't accept the short tag. Actually, PHP's parser is confused by the XML declaration. When you work with generating an XML document with PHP, it only takes one line of code to accommodate PHP's parser. However, the vast majority of the time I'm generating XHTML 1 (or now more and more XHTML 5), and neither of these require the XML declaration for validation purposes. Additionally, wanting to write less code to perform the same action isn't necessarily an act of laziness. Am I lazy for loving the that I can use simple message passing capabilities in Scala or transactional memory in Clojure to perform tasks in parallel as opposed to the olden days of dealing with threads in Java? When I can type less, maintain clarity, and perform the same action, I consider it an act of beauty. When you compare the code samples below, I find that I prefer the short tag version or the last example when I'm reworking the XHTML, as there's less code to sift through. There seems to be a trend in other templating languages to shorten the amount of typing (e.g., Google Go uses http://json-template.googlecode.com/svn/trunk/doc/Introducing-JSON-Template.html), and I hope PHP will continue to keep pace with the trend, too. That said, I'm not taking exception with those who don't use the short tag, only with those who say I shouldn't. Adam {title} {description} {date} -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com
Re: [PHP] Need routine to tell me number of dimensions in array.
Rene Veerman wrote: maybe you should be foreach()ing with references? php.net : search "foreach" : As of PHP 5, you can easily modify array's elements by preceding $value with &. This will assign reference instead of copying the value. This is possible only if iterated array can be referenced (i.e. is variable), References in foreach don't work the way you think they work. You will still incur the copy. At least I did when I tested earlier today :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php