php-general Digest 24 Jun 2008 07:23:44 -0000 Issue 5531
Topics (messages 275850 through 275876):
Re: Military Service WAS [PHP] Capitalization of variable
275850 by: Dotan Cohen
275862 by: Shawn McKenzie
275863 by: Boyd, Todd M.
275865 by: Dotan Cohen
275870 by: Daniel Brown
275871 by: Daniel Brown
275873 by: Shawn McKenzie
275876 by: Sancar Saran
Re: Output Blank?
275851 by: Jim Lucas
275852 by: Dan Shirah
275854 by: Dan Shirah
php.ini and command line
275853 by: Marten Lehmann
275857 by: Wolf
275858 by: Wolf
Re: PHP and Apache
275855 by: Wolf
275856 by: R B
275860 by: Jon Drukman
Re: class as default property
275859 by: Jon Drukman
Uploading files without saving them
275861 by: James Colannino
275864 by: Boyd, Todd M.
275866 by: James Colannino
275867 by: James Colannino
275868 by: Daniel Brown
275869 by: Shawn McKenzie
275872 by: Daniel Brown
Memory profiling tools
275874 by: Larry Garfield
275875 by: Chris
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
2008/6/23 Boyd, Todd M. <[EMAIL PROTECTED]>:
>> I do not know French nor German, so I can only guess that means "cannon
>> snacks"?
>
> Cannon fodder is an informal term for military personnel who are regarded or
> treated as expendable in the face of enemy fire. The term is generally used
> in situations where soldiers are forced to deliberately fight against
> hopeless odds (with the foreknowledge that they will suffer extremely high
> casualties) in an effort to achieve a strategic goal. An example is the
> trench warfare in World War I. The term may also be used (somewhat
> pejoratively) to differentiate infantry from other forces (such as artillery,
> air force or the navy).
>
> The term derives from fodder - food for livestock - however in this case
> soldiers are the metaphorical food for cannons.
>
I hate to say this, but I am expendable. If that's what it takes to
keep my country and my family safe, myself and many other men would
quickly rise to take the fire. The only other real option is artillery
and the Air Force, neither of which can perform the precision work
that we do. Our enemy is hiding among civilians, and our job is to
protect civilians. Whether those are Israeli, Lebanese, or Palestinian
civilians does not matter.
> Shamelessly lifted that from Wikipedia. But yeah, you're right. It was also a
> fantastic video game in the style of Warcraft/Command & Conquer, but before
> its time.
>
I am not familiar with the game, sorry.
Dotan Cohen
http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
--- End Message ---
--- Begin Message ---
Jay Blanchard wrote:
[snip]
www.goarmy.com
http://www.gocoastguard.com/
[/snip]
http://www.airforce.com/
Army, 1990-1995, crypto-ranger!
-shawn (formerly Shawn)
--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Dotan Cohen [mailto:[EMAIL PROTECTED]
> Sent: Monday, June 23, 2008 1:49 PM
> To: Boyd, Todd M.
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] Re: Re: Re: Military Service WAS [PHP]
> Capitalization of variable
---8<--- snip
> > Shamelessly lifted that from Wikipedia. But yeah, you're right. It
> was also a fantastic video game in the style of Warcraft/Command &
> Conquer, but before its time.
> >
>
> I am not familiar with the game, sorry.
Don't be sorry... play it for FREE! :)
http://www.games4win.com/games/cannon-fodder/
Todd Boyd
Web Programmer
--- End Message ---
--- Begin Message ---
2008/6/24 Boyd, Todd M. <[EMAIL PROTECTED]>:
>> I am not familiar with the game, sorry.
>
> Don't be sorry... play it for FREE! :)
> http://www.games4win.com/games/cannon-fodder/
>
Although it seems to install fine in the latest (1.0!) Wine, the game
is unplayable. The screen just flashes. I'll wait until games4lin
comes out, I suppose. Or not.
Dotan Cohen
http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
--- End Message ---
--- Begin Message ---
On Mon, Jun 23, 2008 at 5:41 PM, Shawn McKenzie <[EMAIL PROTECTED]> wrote:
>
> Army, 1990-1995, crypto-ranger!
96 Bravo?
That was the alternative MOS I was considering upon enlisting in
the Army a few years after the Coast Guard. It was between that and
68W (combat medic), and the latter prevailed. I had hoped to work in
to a reclass of 18D (SpecOps Med Sergeant), but before I even got
through the DTP period pre-Basic, I had some family things come up
that needed to take precedence.
Still today, I don't feel as though I'm yet done with the service.
So hopefully after Saturday, when the pre-wife becomes my first wife,
we can discuss the possibility of me joining the Guard or a Reserve
branch. I just want to try to do it before I hit the age limit for
active --- which is coming up quicker and quicker.
--
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.
--- End Message ---
--- Begin Message ---
On Mon, Jun 23, 2008 at 5:58 PM, Dotan Cohen <[EMAIL PROTECTED]> wrote:
>
> Although it seems to install fine in the latest (1.0!) Wine, the game
> is unplayable. The screen just flashes. I'll wait until games4lin
> comes out, I suppose. Or not.
Check your video drivers. Wine 1.0 should be sufficient for
running older abandonware like that.
I've yet to install the 1.0 on any of my systems yet. Let me know
off-list how your experience has been so far, Dotan.
--
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.
--- End Message ---
--- Begin Message ---
When I joined it was 29S, Field COMSEC Equipment Repairer, but in 95
just before I got out they moved it out of signal into ordnance and I
think it was 35E.
What is the age limit now? It doesn't matter much, I don't think I
could run 2 miles in less than 8 hours now anyway. ;-)
-Shawn
Daniel Brown wrote:
On Mon, Jun 23, 2008 at 5:41 PM, Shawn McKenzie <[EMAIL PROTECTED]> wrote:
Army, 1990-1995, crypto-ranger!
96 Bravo?
That was the alternative MOS I was considering upon enlisting in
the Army a few years after the Coast Guard. It was between that and
68W (combat medic), and the latter prevailed. I had hoped to work in
to a reclass of 18D (SpecOps Med Sergeant), but before I even got
through the DTP period pre-Basic, I had some family things come up
that needed to take precedence.
Still today, I don't feel as though I'm yet done with the service.
So hopefully after Saturday, when the pre-wife becomes my first wife,
we can discuss the possibility of me joining the Guard or a Reserve
branch. I just want to try to do it before I hit the age limit for
active --- which is coming up quicker and quicker.
--- End Message ---
--- Begin Message ---
> I hate to say this, but I am expendable. If that's what it takes to
> keep my country and my family safe, myself and many other men would
> quickly rise to take the fire.
/salute
--- End Message ---
--- Begin Message ---
Dan Shirah wrote:
Having some issues with outputting my table data as an array.
In the code below I am outputting the column titles of my table into an
excel spreadsheet. I get the column titles just fine in Excel.
if($numberFields) { // Check if we need to output anything
$types = ifx_fieldtypes($query);
if (isset($types)) {
foreach($types as $field_name[] => $data_type) {
}
}
$headers = join(',', $field_name)."\n"; // Make our first row in the CSV
After that I am pulling all of the column data to place under it's
respective title.
Uncommenting the print_r($info); below does display all of the data for each
column correctly. However, after I run my foreach loop and output the report
to Excel all I get is empty rows/columns where the data should be...on the
bright side I get the exact number of empty rows that my query should
return.
Any ideas why the data isn't populating? If I change $row[] =
parseCSVComments($info->$fieldName); to $row[] = parseCSVComments($info); I
get "Array" printed out in every cell.
while($info = ifx_fetch_row($query)) {
//print_r($info);
foreach($field_name as $fieldName) { // Loop through the array of headers
as we fetch the data
$row[] = parseCSVComments($info->$fieldName);
} // End loop
$data .= join(',', $row)."\n"; // Create a new row of data and append it
to the last row
$row = ''; // Clear the contents of the $row variable to start a new row
}
// Start our output of the CSV
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=data.csv");
header("Pragma: no-cache");
header("Expires: 0");
echo $headers.$data;
}
Thanks,
Dan
<?php
while($info = ifx_fetch_row($query)) {
//print_r($info);
// Initialize/clear the contents of the $row variable
$row = array();
// You probably need to reset the $field_name var with each
// iteration over it. from what I understand, foreach will move
// the internal pointer of the array to the end. Then the next
// iteration over the array will start at the end. BAD!!!
reset($field_name);
// Loop through the array of headers as we fetch the data
foreach($field_name as $fieldName) {
// From the manual: ifx_fetch_row returns an associative array
$row[] = parseCSVComments($info[$fieldName]);
} // End loop
// Create a new row of data and append it to the last row
$data .= join(',', $row)."\n";
} // End while
?>
BTW: what are you doing, if anything, if your data has a comma in it?
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--- End Message ---
--- Begin Message ---
AH HA! Got it!
The problem was I did not need to loop through the array headers to
associate the data. So I removed:
foreach($field_name as $fieldName) { // Loop through the array of headers
as we fetch the data
$row[] = parseCSVComments($info->$fieldName);
} // End loop
And ran it as:
while($info = ifx_fetch_row($query)) {
//print_r($info);
$data .= join(',', $row)."\n"; // Create a new row of data and append it
to the last row
$row = ''; // Clear the contents of the $row variable to start a new row
}
And everything output correctly!
Dan
--- End Message ---
--- Begin Message ---
>
> // Initialize/clear the contents of the $row variable
> $row = array();
>
> // You probably need to reset the $field_name var with each
> // iteration over it. from what I understand, foreach will move
> // the internal pointer of the array to the end. Then the next
> // iteration over the array will start at the end. BAD!!!
> reset($field_name);
>
>
>
> BTW: what are you doing, if anything, if your data has a comma in it?
Jim,
I took your advice about clearing the array and resetting the $field_name
variable. Thanks!
I am not worried about comma's in my data because my application
and database do not allow comma's to be input for this information. :)
Dan
--- End Message ---
--- Begin Message ---
Hello,
within a CGI-wrapped hosting environment, we are calling PHP as command
line interpreter (not cli). This works fine, except one thing: Settings
from parent php.inis are not inherited. This is very annoying. Lets say,
there is a script /user/123/index.php and some libraries in
/user/123/include/*.php, then settings from /user/123/php.ini are not
available for /user/123/include/*.php, even if the environment-variable
DOCUMENT_ROOT is set to /user, so PHP would be able to look for settings
in php.ini beginning in /user and ending in the current directory
/user/123 or /user/123/include.
Why does PHP work different here in the command line mode as in the
Apache-Module mode?
Is there a way to enable php.ini-inheritance for command line PHP?
Regards
Marten
--- End Message ---
--- Begin Message ---
---- Marten Lehmann <[EMAIL PROTECTED]> wrote:
> Hello,
>
> within a CGI-wrapped hosting environment, we are calling PHP as command
> line interpreter (not cli). This works fine, except one thing: Settings
> from parent php.inis are not inherited. This is very annoying. Lets say,
> there is a script /user/123/index.php and some libraries in
> /user/123/include/*.php, then settings from /user/123/php.ini are not
> available for /user/123/include/*.php, even if the environment-variable
> DOCUMENT_ROOT is set to /user, so PHP would be able to look for settings
> in php.ini beginning in /user and ending in the current directory
> /user/123 or /user/123/include.
>
> Why does PHP work different here in the command line mode as in the
> Apache-Module mode?
>
> Is there a way to enable php.ini-inheritance for command line PHP?
>
> Regards
> Marten
Have you tried modifying your command line php calls with a -c as some of the
documentation states?
What have you tried (direct calls) and what has the output been?
What do your error logs say?
HTH,
Wolf
--- End Message ---
--- Begin Message ---
---- Marten Lehmann <[EMAIL PROTECTED]> wrote:
> Hello,
>
> within a CGI-wrapped hosting environment, we are calling PHP as command
> line interpreter (not cli). This works fine, except one thing: Settings
> from parent php.inis are not inherited. This is very annoying. Lets say,
> there is a script /user/123/index.php and some libraries in
> /user/123/include/*.php, then settings from /user/123/php.ini are not
> available for /user/123/include/*.php, even if the environment-variable
> DOCUMENT_ROOT is set to /user, so PHP would be able to look for settings
> in php.ini beginning in /user and ending in the current directory
> /user/123 or /user/123/include.
>
> Why does PHP work different here in the command line mode as in the
> Apache-Module mode?
>
> Is there a way to enable php.ini-inheritance for command line PHP?
>
> Regards
> Marten
>
Also, if you do use Google and search, the first answer it comes back with is
this link:
http://bugs.php.net/bug.php?id=44526&edit=1
So, just wondering here, what searches did you run?
http://www.google.com/search?hl=en&client=firefox-a&rls=com.ubuntu%3Aen-US%3Aunofficial&hs=jaC&q=PHP%3A+php.ini+inheritance++cli&btnG=Search
Wolf
--- End Message ---
--- Begin Message ---
---- R B <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I´m developing a PHP system that needs one of these lines in the .htaccess,
> depending of the server configuration:
>
> AddHandler application/x-httpd-php .xyz
> or
>
> AddHandler application/x-httpd-php4 .xyz
>
> or
>
> AddHandler application/x-httpd-php5 .xyz
>
> How can i detect "on the fly" which line i have to use?
Why not just read the manual and add the appropriate line for your version of
PHP ?
Makes the most sense.
Or add all the lines.
Pretty much an Apache list question though.
Wolf
--- End Message ---
--- Begin Message ---
The people that will install this system, don´t have programming knowledge.
They have a website, buy don´t have knowledge of configurations.
If i add all the lines, it don´t works, unless the last line is the correct
for that particular server.
>
>
> Why not just read the manual and add the appropriate line for your version
> of PHP ?
>
> Makes the most sense.
>
> Or add all the lines.
>
> Pretty much an Apache list question though.
>
> Wolf
>
--- End Message ---
--- Begin Message ---
R B wrote:
Hello,
I´m developing a PHP system that needs one of these lines in the .htaccess,
depending of the server configuration:
AddHandler application/x-httpd-php .xyz
or
AddHandler application/x-httpd-php4 .xyz
or
AddHandler application/x-httpd-php5 .xyz
How can i detect "on the fly" which line i have to use?
<IfModule php5_module>
AddHandler application/x-httpd-php5 .xyz
</IfModule>
<IfModule php4_module>
AddHandler application/x-httpd-php4 .xyz
</IfModule>
--- End Message ---
--- Begin Message ---
Chetan Rane wrote:
But this does not work:
<?php
class Foo {
}
class Bar {
function __construct() {
public $f = new Foo();
}
}
?>
do this:
<?php
class Foo {
}
class Bar {
public $f;
function __construct() {
$this->f = new Foo();
}
}
$x = new Bar();
print_r($x->f);
?>
--- End Message ---
--- Begin Message ---
Hey everyone. Here's a simple question. I'd like to be able to import
information from a text file located on the client without actually
saving it on the server; that is, I simply want to read the data into
memory on the server, without actually saving it to a file.
I've been googling around to learn about uploading files via PHP, but
haven't found anything yet (I could save the file to a temporary
location and delete it when finished, but I'd prefer not to have to do
this if at all possible.)
Anyone have any ideas? Thanks! :)
James
--
My blog: http://www.crazydrclaw.com/
My homepage: http://james.colannino.org/
"Black holes are where God divided by zero." --Steven Wright
--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: James Colannino [mailto:[EMAIL PROTECTED]
> Sent: Monday, June 23, 2008 3:48 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Uploading files without saving them
>
> Hey everyone. Here's a simple question. I'd like to be able to
import
> information from a text file located on the client without actually
> saving it on the server; that is, I simply want to read the data into
> memory on the server, without actually saving it to a file.
>
> I've been googling around to learn about uploading files via PHP, but
> haven't found anything yet (I could save the file to a temporary
> location and delete it when finished, but I'd prefer not to have to do
> this if at all possible.)
>
> Anyone have any ideas? Thanks! :)
IIRC, if you never move it out of PHP's defaulted temporary storage
sandbox, it will eventually be wiped. When files are uploaded via PHP,
they must explicitly be moved into the active file system.
HTH,
Todd Boyd
Web Programmer
--- End Message ---
--- Begin Message ---
Boyd, Todd M. wrote:
IIRC, if you never move it out of PHP's defaulted temporary storage
sandbox, it will eventually be wiped. When files are uploaded via PHP,
they must explicitly be moved into the active file system.
Ah, I see. What would happen if two people just happened to upload
files with the same filename at the same time? Would one stomp over the
other, or does PHP have mechanisms to handle that sort of situation?
James
--
My blog: http://www.crazydrclaw.com/
My homepage: http://james.colannino.org/
"Black holes are where God divided by zero." --Steven Wright
--- End Message ---
--- Begin Message ---
Nitsan Bin-Nun wrote:
PHP uses randomaly name for each of them (during the upload to the
temporary directory), when its done PHP moves the file to the objective
location, i dont think you will obstacle filename problems.
Ah, excellent! Thanks :)
James
--
My blog: http://www.crazydrclaw.com/
My homepage: http://james.colannino.org/
"Black holes are where God divided by zero." --Steven Wright
--- End Message ---
--- Begin Message ---
On Mon, Jun 23, 2008 at 6:05 PM, James Colannino <[EMAIL PROTECTED]> wrote:
>
> Ah, I see. What would happen if two people just happened to upload files
> with the same filename at the same time? Would one stomp over the other, or
> does PHP have mechanisms to handle that sort of situation?
Todd is correct. When you upload a file, it's saved to a
temporary directory with a unique filename. Thus, if six people
upload the file `summer.jpg`, you may instead see on the server side:
/tmp/PHPf983D93j
/tmp/PHPOg4ji23
/tmp/PHPeklS83q
.... and so on.
Further, as Todd mentioned, unless you explicitly call
move_uploaded_files() or perform a similar action, the file will be
deleted as soon as the Apache child process dies --- which happens as
soon as script execution completes.
Keep in mind that this is all assuming that you're using Apache on
a *NIX-like system. If you're using IIS, Windows, or anything else,
your mileage may vary.
--
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.
--- End Message ---
--- Begin Message ---
Daniel Brown wrote:
On Mon, Jun 23, 2008 at 6:05 PM, James Colannino <[EMAIL PROTECTED]> wrote:
Ah, I see. What would happen if two people just happened to upload files
with the same filename at the same time? Would one stomp over the other, or
does PHP have mechanisms to handle that sort of situation?
Todd is correct. When you upload a file, it's saved to a
temporary directory with a unique filename. Thus, if six people
upload the file `summer.jpg`, you may instead see on the server side:
/tmp/PHPf983D93j
/tmp/PHPOg4ji23
/tmp/PHPeklS83q
.... and so on.
Further, as Todd mentioned, unless you explicitly call
move_uploaded_files() or perform a similar action, the file will be
deleted as soon as the Apache child process dies --- which happens as
soon as script execution completes.
Keep in mind that this is all assuming that you're using Apache on
a *NIX-like system. If you're using IIS, Windows, or anything else,
your mileage may vary.
Oooo... where can I get this 'summer.jpg'?
--- End Message ---
--- Begin Message ---
On Mon, Jun 23, 2008 at 8:17 PM, Shawn McKenzie <[EMAIL PROTECTED]> wrote:
>>
> Oooo... where can I get this 'summer.jpg'?
It's an Easter Egg embedded in the $_FILES array under an
undocumented hidden key.
<?php
move_uploaded_file($_FILES['BITE_MY_SHINY_METAL_ASS'],dirname(__FILE__).'/summer.jpg');
?>
--
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.
--- End Message ---
--- Begin Message ---
Hi all. I have a rather large application on which I need to do some memory
performance profiling and optimization. Basically it's eating up more RAM
than it should and I'm not sure why. I have some suspects, but nothing
concrete.
Are there any (open source) tools that people can recommend for such a task?
Or any programming tricks one can recommend to identify the size of a given
data structure? Windows or Linux are both fine; I have access to both.
--
Larry Garfield
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Larry Garfield wrote:
> Hi all. I have a rather large application on which I need to do some memory
> performance profiling and optimization. Basically it's eating up more RAM
> than it should and I'm not sure why. I have some suspects, but nothing
> concrete.
>
> Are there any (open source) tools that people can recommend for such a task?
> Or any programming tricks one can recommend to identify the size of a given
> data structure? Windows or Linux are both fine; I have access to both.
You could use ticks:
http://www.davedevelopment.co.uk/2008/05/12/log-memory-usage-using-declare-and-ticks-in-php/
though see my comments (#7) about why you don't want to store the info
in php itself :P
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---