OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 22 Jul 2003 06:44:29 -0000 Issue 2190

php-general-digest-helplists.php.net
Date: Tue Jul 22 2003 - 01:44:29 CDT


php-general Digest 22 Jul 2003 06:44:29 -0000 Issue 2190

Topics (messages 156095 through 156182):

Changing numbers
        156095 by: zavaboy
        156096 by: Jay Blanchard
        156098 by: zavaboy
        156099 by: James Rodenkirch
        156100 by: James Rodenkirch
        156101 by: zavaboy
        156106 by: Jay Blanchard
        156111 by: John Nichel
        156113 by: bob parker
        156114 by: John Nichel
        156140 by: Curt Zirzow
        156143 by: justin gruenberg
        156148 by: Roger B.A Klorese
        156152 by: Brad Pauly
        156155 by: Roger B.A Klorese

Re: CSV import
        156097 by: Jay Blanchard
        156139 by: Curt Zirzow

Re: need help with MySQL full text searching!!!!
        156102 by: CPT John W. Holmes

Re: need help with mysql union
        156103 by: CPT John W. Holmes

IE Issues
        156104 by: Stephen
        156108 by: Stephen
        156109 by: Jaime Bozza
        156115 by: Stephen
        156121 by: David Goodchild
        156141 by: Curt Zirzow

Re: Passing Serialized Array via Hidden field
        156105 by: CPT John W. Holmes
        156107 by: Chris Shiflett

regexp help...
        156110 by: Doug La Farge
        156112 by: Doug La Farge

can't restart session
        156116 by: Chris W. Parker
        156117 by: CPT John W. Holmes
        156118 by: James Rodenkirch
        156119 by: Adrian Portsmouth
        156120 by: Chris W. Parker
        156123 by: CPT John W. Holmes
        156125 by: Chris W. Parker
        156128 by: Gabriel Guzman
        156129 by: CPT John W. Holmes
        156136 by: Chris W. Parker
        156146 by: CPT John W. Holmes

Re: POSIX seteuid and similar
        156122 by: David Goodchild
        156124 by: Doug La Farge

filesize comparison for upload
        156126 by: mac-robots.earthlink.net
        156127 by: CPT John W. Holmes

Re: Help?
        156130 by: Curt Zirzow

Re: SQL select
        156131 by: Curt Zirzow

Re: help with ad serving
        156132 by: Curt Zirzow

Re: Register Globals
        156133 by: Curt Zirzow
        156167 by: Justin French

Re: Help with Date
        156134 by: Curt Zirzow
        156135 by: Curt Zirzow

Re: How to..
        156137 by: ComexEP
        156142 by: Chris W. Parker
        156144 by: ComexEP
        156147 by: Doug La Farge

Problem with Adding info into an array
        156138 by: Phillip Blancher
        156145 by: CPT John W. Holmes

Oracle Odbc Connection Problem
        156149 by: angel

Trouble connection to Postgres DB
        156150 by: Nelson Ferreira Jr

MIME decoder for use as the target of an Alias?
        156151 by: Larry Rosenman
        156153 by: James Rodenkirch
        156154 by: James Rodenkirch

Re: Auto session timeout
        156156 by: CPT John W. Holmes

Socket programming with PHP risky?
        156157 by: René Fournier
        156175 by: Curt Zirzow
        156176 by: Chris Shiflett
        156177 by: Curt Zirzow

Running PHP as CGI
        156158 by: David Goodchild
        156172 by: David Robley

fsockopen
        156159 by: Doug La Farge
        156173 by: Curt Zirzow

backtick operator and zombie processes
        156160 by: jeff.unixisgod.com

same operation to multiple files
        156161 by: jwulff
        156170 by: Curt Zirzow
        156171 by: David Robley

Converting a MySQL result into a complex array
        156162 by: jwulff
        156166 by: Curt Zirzow

replacing everything between 2 strings
        156163 by: Matt Palermo
        156164 by: Daryl Meese
        156165 by: Matt Palermo
        156169 by: Curt Zirzow
        156174 by: Lee Doolan

Re: News Reader
        156168 by: David Robley

controlling winamp with COM
        156178 by: John Herren
        156179 by: Diego Fulgueira
        156180 by: Robert Cummings
        156181 by: Joseph Blythe

feof() problem
        156182 by: chandrakant Reddy

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


I have the following numbers:

12.400
666.75
23
369.2
3.234

How can I make them have at least 2 decimal places?
So, they will output:

12.40
666.75
23.00
269.20
3.234

Thanks in advance!

--

- Zavaboy
zavaboyhotmail.com
www.zavaboy.com

attached mail follows:


[snip]
How can I make them have at least 2 decimal places?
[/snip]

RTFM at http://www.php.net/number_format

HTH!

attached mail follows:


What about if I had 2.856 that function will make it 2.86.

"Jay Blanchard" <jay.blanchardniicommunications.com> wrote in message
news:C8F323573C030A448F3E5A2B6FE2070B0101F95Anemesis...
[snip]
How can I make them have at least 2 decimal places?
[/snip]

RTFM at http://www.php.net/number_format

HTH!

attached mail follows:


try rounding it first

http://www.php.net/manual/en/function.round.php

Zavaboy wrote:

> What about if I had 2.856 that function will make it 2.86.
>
>
> "Jay Blanchard" <jay.blanchardniicommunications.com> wrote in message
> news:C8F323573C030A448F3E5A2B6FE2070B0101F95Anemesis...
> [snip]
> How can I make them have at least 2 decimal places?
> [/snip]
>
> RTFM at http://www.php.net/number_format
>
> HTH!
>
>

attached mail follows:


try rounding it first

http://www.php.net/manual/en/function.round.php

Zavaboy wrote:

> What about if I had 2.856 that function will make it 2.86.
>
>
> "Jay Blanchard" <jay.blanchardniicommunications.com> wrote in message
> news:C8F323573C030A448F3E5A2B6FE2070B0101F95Anemesis...
> [snip]
> How can I make them have at least 2 decimal places?
> [/snip]
>
> RTFM at http://www.php.net/number_format
>
> HTH!
>
>

attached mail follows:


*Sigh*, lets say I have:

2.65
3.3
5.2670
12.030

I would like it at least 2 decimal places.. So, 5.2670 would be 5.267 not
5.27:

2.65
3.30
5.267
12.03

"James Rodenkirch" <jamesrez-net.com> wrote in message
news:3F1C298E.80602ez-net.com...
> try rounding it first
>
> http://www.php.net/manual/en/function.round.php
>
> Zavaboy wrote:
>
> > What about if I had 2.856 that function will make it 2.86.
> >
> >
> > "Jay Blanchard" <jay.blanchardniicommunications.com> wrote in message
> > news:C8F323573C030A448F3E5A2B6FE2070B0101F95Anemesis...
> > [snip]
> > How can I make them have at least 2 decimal places?
> > [/snip]
> >
> > RTFM at http://www.php.net/number_format
> >
> > HTH!
> >
> >
>

attached mail follows:


[snip]
I would like it at least 2 decimal places.. So, 5.2670 would be 5.267
not
5.27:
[/snip]

RTFM for formatted string http://us3.php.net/sprintf or
http://us3.php.net/printf

HTH

attached mail follows:


zavaboy wrote:
> *Sigh*, lets say I have:
>
> 2.65
> 3.3
> 5.2670
> 12.030
>
> I would like it at least 2 decimal places.. So, 5.2670 would be 5.267 not
> 5.27:
>
> 2.65
> 3.30
> 5.267
> 12.03
>
> "James Rodenkirch" <jamesrez-net.com> wrote in message
> news:3F1C298E.80602ez-net.com...
>
>>try rounding it first
>>
>>http://www.php.net/manual/en/function.round.php
>>
>>Zavaboy wrote:
>>
>>
>>>What about if I had 2.856 that function will make it 2.86.
>>>
>>>
>>>"Jay Blanchard" <jay.blanchardniicommunications.com> wrote in message
>>>news:C8F323573C030A448F3E5A2B6FE2070B0101F95Anemesis...
>>>[snip]
>>>How can I make them have at least 2 decimal places?
>>>[/snip]
>>>
>>>RTFM at http://www.php.net/number_format
>>>
>>>HTH!
>>>
>>>
>>
>

*Sigh*

RTFM - http://us4.php.net/sprintf

attached mail follows:


On Tue, 22 Jul 2003 04:03, zavaboy wrote:
> *Sigh*, lets say I have:
>
> 2.65
> 3.3
> 5.2670
> 12.030
>
> I would like it at least 2 decimal places.. So, 5.2670 would be 5.267 not
> 5.27:
>

5.267 is 3 decimal places - count them

attached mail follows:


bob parker wrote:
> On Tue, 22 Jul 2003 04:03, zavaboy wrote:
>
>>*Sigh*, lets say I have:
>>
>>2.65
>>3.3
>>5.2670
>>12.030
>>
>>I would like it at least 2 decimal places.. So, 5.2670 would be 5.267 not
>>5.27:
>>
>
>
> 5.267 is 3 decimal places - count them
>

He said "at least 2 decimal places", not "exactally two decimal places".

attached mail follows:


* Thus wrote zavaboy (zavaboyhotmail.com):
> I have the following numbers:
>
> 12.400
> 666.75
> 23
> 369.2
> 3.234
>
> How can I make them have at least 2 decimal places?
> So, they will output:
>
> 12.40
> 666.75
> 23.00
> 269.20
> 3.234
>
> Thanks in advance!

http://php.net/number_format
or
http://php.net/printf

Curt
--
"I used to think I was indecisive, but now I'm not so sure."

attached mail follows:


Curt Zirzow wrote:

>* Thus wrote zavaboy (zavaboyhotmail.com):
>
>
>>I have the following numbers:
>>
>>12.400
>>666.75
>>23
>>369.2
>>3.234
>>
>>How can I make them have at least 2 decimal places?
>>So, they will output:
>>
>>12.40
>>666.75
>>23.00
>>269.20
>>3.234
>>
>>Thanks in advance!
>>

What I dont understand is that your examples are not consitant. You
want 2 or more decimal positions, so as if there are more than 2, to
leave what exists. But your first example, you truncate the last 0. Is
that a typo, or intentional?

attached mail follows:


> From: justin gruenberg [mailto:justinice.kewlio.net]
> Subject: Re: [PHP] Changing numbers
>
>
> Curt Zirzow wrote:
>
> >* Thus wrote zavaboy (zavaboyhotmail.com):
> >
> >
> >>I have the following numbers:
> >>
> >>12.400
> >>666.75
> >>23
> >>369.2
> >>3.234
> >>
> >>How can I make them have at least 2 decimal places?
> >>So, they will output:
> >>
> >>12.40
> >>666.75
> >>23.00
> >>269.20
> >>3.234
> >>
> >>Thanks in advance!
> >>
>
> What I dont understand is that your examples are not consitant. You
> want 2 or more decimal positions, so as if there are more than 2, to
> leave what exists. But your first example, you truncate the
> last 0. Is
> that a typo, or intentional?

What's so hard about this?

He wants two or more *significant* positions preserved. Show to at least
two decimal places, trailing zeroes truncated beyond the 2nd decimal place.

attached mail follows:


Roger B.A Klorese wrote:

>>>* Thus wrote zavaboy (zavaboyhotmail.com):
>>>
>>>
>>>
>>>>I have the following numbers:
>>>>
>>>>12.400
>>>>666.75
>>>>23
>>>>369.2
>>>>3.234
>>>>
>>>>How can I make them have at least 2 decimal places?
>>>>So, they will output:
>>>>
>>>>12.40
>>>>666.75
>>>>23.00
>>>>269.20
>>>>3.234
>
> What's so hard about this?
>
> He wants two or more *significant* positions preserved. Show to at least
> two decimal places, trailing zeroes truncated beyond the 2nd decimal place.

I am not sure what he is after, but I don't think it has to do with
significant figures (if that is what you meant). If that was the case,
12.400 should remain 12.400. Trailing zeros to the right of a decimal
are significant.

- Brad

attached mail follows:


> From: Brad Pauly [mailto:bradrobinsontech.com]
> Sent: Monday, July 21, 2003 2:45 PM
> To: Roger B.A Klorese
> Cc: 'justin gruenberg'; 'Curt Zirzow'; 'PHP-General'
> Subject: Re: [PHP] Changing numbers
>
>
> I am not sure what he is after, but I don't think it has to do with
> significant figures (if that is what you meant). If that was
> the case,
> 12.400 should remain 12.400. Trailing zeros to the right of a decimal
> are significant.

Perhaps. But he's saying that, for his purposes, they're not -- if anything
to the right of the last shown zero existed, it would be reflected in the
output.

attached mail follows:


[snip]
When using something like this:
LOAD DATA LOCAL INFILE '/tmp/phpKBjUWb' INTO TABLE `indoma` FIELDS
TERMINATED BY ',' LINES TERMINATED BY '\r\n'

How do I also insert a field not in the CSV. For example there are 8
fields
in the CSV and 9 in the table. I want the ninth field to be the name of
the
CSV file. How do I do this? Can't find any mention of it on mysql.com.
[/snip]

Instead of LOAD DATA INFILE see ....

http://www.php.net/fgetcsv

HTH!

attached mail follows:


* Thus wrote jwulff (johnworcasnet.com):
> When using something like this:
> LOAD DATA LOCAL INFILE '/tmp/phpKBjUWb' INTO TABLE `indoma` FIELDS
> TERMINATED BY ',' LINES TERMINATED BY '\r\n'
>
> How do I also insert a field not in the CSV. For example there are 8 fields
> in the CSV and 9 in the table. I want the ninth field to be the name of the
> CSV file. How do I do this? Can't find any mention of it on mysql.com.
My suggestion is to go here:

http://www.mysql.com/documentation/lists.html
 

Curt
--
"I used to think I was indecisive, but now I'm not so sure."

attached mail follows:


I think you need to make a second index that just consists of the one column

ALTER TABLE biblio ADD FULLTEXT (title)

if you want to search on just that one column.

---John Holmes...

----- Original Message -----
From: "Angelo Zanetti" <binc2ctech.ac.za>
To: <php-generallists.php.net>
Sent: Monday, July 21, 2003 12:09 PM
Subject: [PHP] need help with MySQL full text searching!!!!

Hi

I have a table which contains 3 fields (ID, Title, Abstract) the title and
abstract fields have been fulltext indexes like this:

ALTER TABLE biblio ADD FULLTEXT (title,abstract);

that worked fine, however my problem is whenever I want to do a select
statement only comparing 1 of the columns to inputted data ( in a Select
statement):

$result = mysql_query("SELECT * FROM Biblio WHERE MATCH (title) AGAINST
('$searchString')");

It gives me this error: Can't find FULLTEXT index matching the column list.
It appears that i cant just compare a single fulltext indexed column if
there are other fulltext indexed columns. When I try it with both columns
then it works but I just want to compare 1 column. eg:
$result = mysql_query("SELECT * FROM Biblio WHERE MATCH (title, abstract)
AGAINST ('$searchString')");

So is there anyway that I can just compare 1 column with text entered? Do I
have t make some sort of temporary table to do this? All the examples I have
found show the select statement with 2 columns or if they use 1 coumn its
because there is only 1 column in their table.

Any help would be appreciated!

TIA

Angelo

ps. sorry that this may be a bit off topic

attached mail follows:


> hi, i'm trying to select * through 3 tables - is the following syntax
correct?
>
> $sql="(SELECT * FROM mjp_cc)";
> $sql="UNION";
> $sql="(SELECT * FROM imc_cc)";
> $sql="UNION";
> $sql="(SELECT * FROM pmp_cc)";
> $sql.=" ORDER BY savedccactivity DESC";
>
> i basically just want to spit out the contents of these tables...
>
> also - how would this type of query work if the name 'savedccactivity' is
> different in all 3
> tables?

This is a MySQL question, first of all.

Second, you need to rename the column in each table to 'savedccactivity' if
you want to order the whole result by that.

(SELECT foo AS column FROM table1)
UNION
(SELECT bar AS column FROM table2)
UNION
(SELECT abc AS column FROM table3)
ORDER BY column DESC

---John Holmes...

attached mail follows:


Hello,

This is a little off topic but I do need some help. I have had IE 6 for
about a month now (just got a new computer in June and have been using IE6
since). When I first started running it, it was fine. A few weeks ago,
though, all my fonts have greatly increased and I have done nothing that
would cause this.

If I make a webpage that has <font size="1"> then IE will display the font
at size 3 or 4. I have no idea why either. I have put a default style sheet
on IE to make all the fonts a certain size but this is getting annoying
since only some are getting resized.

I have run the Accessibilty wizard on Windows XP Pro but it did nothing. For
reference, here is my accessibility settings in IE6:

http://www.melchior.us/ieissues/acc.gif

If I turn off the style sheet option, then here is what all the fonts look
like:

http://www.melchior.us/ieissues/font_big.gif

Now if I turn on the style sheet, this is what the fonts look like:

http://www.melchior.us/ieissues/font_small.gif

If anyone has any ideas how to fix this, please let me know! I've already
tried uninstalling and reinstalling IE but there was no luck. Please reply
soon.

Thank you,
Stephen Craton
Senior Executive Web Developer
Mophus.com, Inc.
Lead Programmer/Webmaster
WiredPHP (http://php.melchior.us)

attached mail follows:


Thank you so much! I now have to wonder how it got set to that. Probably my
brothers or that power surge a while back. Anyway, thanks again!

Thank you,
Stephen Craton
Senior Executive Web Developer
Mophus.com, Inc.
Lead Programmer/Webmaster
WiredPHP (http://php.melchior.us)

----- Original Message -----
From: "Chris W. Parker" <cparkerswatgear.com>
To: "Stephen" <webmastermelchior.us>
Sent: Monday, July 21, 2003 1:13 PM
Subject: RE: [PHP] IE Issues

Stephen <mailto:webmastermelchior.us>
    on Monday, July 21, 2003 11:11 AM said:

> If I make a webpage that has <font size="1"> then IE will display the
> font at size 3 or 4. I have no idea why either. I have put a default
> style sheet on IE to make all the fonts a certain size but this is
> getting annoying since only some are getting resized.

Is your text scaled? That's the only reason I think of.

View > Text Size > Medium (default)

You might be on Larger or Largest.

c.

p.s. FIRST POST!!

attached mail follows:


Ctrl-MouseWheel will increase or decrease the text size in an IE browser
window. I've found that I've accidentally increased the font size since I
use the Mouse Wheel quite a bit. (As well as CTRL-W to close an IE window
if one pops up)

Jaime Bozza

> -----Original Message-----
> From: Stephen [mailto:webmastermelchior.us]
> Sent: Monday, July 21, 2003 1:21 PM
> To: Chris W. Parker
> Cc: PHP List
> Subject: Re: [PHP] IE Issues
>
>
> Thank you so much! I now have to wonder how it got set to
> that. Probably my
> brothers or that power surge a while back. Anyway, thanks again!
>
> Thank you,
> Stephen Craton
> Senior Executive Web Developer
> Mophus.com, Inc.
> Lead Programmer/Webmaster
> WiredPHP (http://php.melchior.us)
>
>
> ----- Original Message -----
> From: "Chris W. Parker" <cparkerswatgear.com>
> To: "Stephen" <webmastermelchior.us>
> Sent: Monday, July 21, 2003 1:13 PM
> Subject: RE: [PHP] IE Issues
>
>
> Stephen <mailto:webmastermelchior.us>
> on Monday, July 21, 2003 11:11 AM said:
>
> > If I make a webpage that has <font size="1"> then IE will
> display the
> > font at size 3 or 4. I have no idea why either. I have put a default
> > style sheet on IE to make all the fonts a certain size but this is
> > getting annoying since only some are getting resized.
>
> Is your text scaled? That's the only reason I think of.
>
> View > Text Size > Medium (default)
>
> You might be on Larger or Largest.
>
>
> c.
>
> p.s. FIRST POST!!
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


Hmm, yeah, you're probably right. I probably did push CTRL+MouseWheel since
I use it a lot and CTRL+C. Thanks for the info.

The power surge did do a lot of funky stuff to my files. I found bits of
messed up code here and there and my date was set to 2069. Thank goodness
for System Restore. ^_^ Thanks again!

Thank you,
Stephen Craton
Senior Executive Web Developer
Mophus.com, Inc.
Lead Programmer/Webmaster
WiredPHP (http://php.melchior.us)

----- Original Message -----
From: "Chris W. Parker" <cparkerswatgear.com>
To: "Stephen" <webmastermelchior.us>
Sent: Monday, July 21, 2003 1:29 PM
Subject: RE: [PHP] IE Issues

Stephen <mailto:webmastermelchior.us>
    on Monday, July 21, 2003 11:21 AM said:

> Thank you so much! I now have to wonder how it got set to that.
> Probably my brothers or that power surge a while back. Anyway, thanks
> again!

Maybe it was your brothers but definitely not a power surge. If a power
surge were to interfere with your computer in a negative way it wouldn't
change the size of your font in IE.

Do you have a scroll wheel on your mouse? Is it possible you pressed
Ctrl-Scroll up/down at the same time at any point? Probably. That's the
most likely situation. It's really a handy tool, try it out.

c.

attached mail follows:


You need to open IE6 and do this:
Goto View -> Text Size -> Medium

Sometimes this can accidently change

"Stephen" <webmastermelchior.us> wrote in message
news:002b01c34fb3$64fb31b0$0700a8c0melchior3066...
> Hello,
>
> This is a little off topic but I do need some help. I have had IE 6 for
> about a month now (just got a new computer in June and have been using IE6
> since). When I first started running it, it was fine. A few weeks ago,
> though, all my fonts have greatly increased and I have done nothing that
> would cause this.
>
> If I make a webpage that has <font size="1"> then IE will display the font
> at size 3 or 4. I have no idea why either. I have put a default style
sheet
> on IE to make all the fonts a certain size but this is getting annoying
> since only some are getting resized.
>
> I have run the Accessibilty wizard on Windows XP Pro but it did nothing.
For
> reference, here is my accessibility settings in IE6:
>
> http://www.melchior.us/ieissues/acc.gif
>
> If I turn off the style sheet option, then here is what all the fonts look
> like:
>
> http://www.melchior.us/ieissues/font_big.gif
>
> Now if I turn on the style sheet, this is what the fonts look like:
>
> http://www.melchior.us/ieissues/font_small.gif
>
> If anyone has any ideas how to fix this, please let me know! I've already
> tried uninstalling and reinstalling IE but there was no luck. Please reply
> soon.
>
> Thank you,
> Stephen Craton
> Senior Executive Web Developer
> Mophus.com, Inc.
> Lead Programmer/Webmaster
> WiredPHP (http://php.melchior.us)
>
>

attached mail follows:


* Thus wrote Stephen (webmastermelchior.us):
> Hello,
>
> This is a little off topic but I do need some help. I have had IE 6 for
> about a month now (just got a new computer in June and have been using IE6
> since). When I first started running it, it was fine. A few weeks ago,
> though, all my fonts have greatly increased and I have done nothing that
> would cause this.
>
> If I make a webpage that has <font size="1"> then IE will display the font

Dont use the font tag.. they are evil... and besides depricated.

Curt
--
"I used to think I was indecisive, but now I'm not so sure."

attached mail follows:


> --- Andrei Verovski <andreil1mail.starlett.lv> wrote:
> > I am need to pass serialized assotiative array via form hidden
> > field (not GET or POST).
>
> This is impossible. A hidden form field is simply a form field that is not
> displayed to the user. Form actions must be GET or POST.
>
> > In order to do it, I did the following: urlencode(serialize($my_array)).
>
> Don't URL encode the value of the form field, since the browser will take
care
> of that. You should probably use POST rather than GET, because serializing
an
> array might yield a very long string and make the URL too large for the
Web
> browser and/or Web server to handle.

I didn't see the original thread, but judging from the title, this is how
you'd do it:

<input type="hidden" name="serialized_array"
value="<?=htmlentities(serialize($array))?>">

And to retrieve:

$array = unserialize(stripslashes($_POST['serialized_array']));
(assuming magic_quotes_gpc is ON)

---John Holmes...

attached mail follows:


--- John Manko <xeridadelphia.net> wrote:
> Just a small point, you can have both GET and POST.
>
> ------ search.html -----
> <form method=POST
> action='page.php?...

Notice your form method is POST, not both GET and POST. The HTTP request sent
after a user submits this form will be a POST request, even though you do have
GET variables. Try not to confuse GET/POST variables with GET/POST request
methods.

Chris

=====
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/

attached mail follows:


Hi all,

I have a string that for all practical purposes should probably be a
list (array). I need one line from the string and need to send the
rest to /dev/null.

The string starts:
HTTP/1.1 200 OK
Date: Tue, 22 Jul 2003 01:34:12 GMT
Server: Apache/1.3.27 (Unix) mod_jk/1.1.0 mod_ssl/2.8.12 OpenSSL/0.9.6g
Set-Cookie: JSESSIONID=mngtpma6i1;Path=/Interface
Connection: close
Content-Type: text/html;charset=ISO-8859-1

<?xml version="1.0"?> blah blah blah </shipment>

The String ends on the line above (white space line).

If I'm not mistaken the blank lines are actually a combo of unix and
dos line returns.

any help is much appreciated.

thanks,

attached mail follows:


I guess I should point out that the line i want is the XML line
'<?xml......'

On Monday, July 21, 2003, at 11:44 AM, Doug La Farge wrote:

> Hi all,
>
> I have a string that for all practical purposes should probably be a
> list (array). I need one line from the string and need to send the
> rest to /dev/null.
>
> The string starts:
> HTTP/1.1 200 OK
> Date: Tue, 22 Jul 2003 01:34:12 GMT
> Server: Apache/1.3.27 (Unix) mod_jk/1.1.0 mod_ssl/2.8.12 OpenSSL/0.9.6g
> Set-Cookie: JSESSIONID=mngtpma6i1;Path=/Interface
> Connection: close
> Content-Type: text/html;charset=ISO-8859-1
>
>
>
>
>
>
>
>
>
>
> <?xml version="1.0"?> blah blah blah </shipment>
>
>
>
> The String ends on the line above (white space line).
>
> If I'm not mistaken the blank lines are actually a combo of unix and
> dos line returns.
>
> any help is much appreciated.
>
> thanks,

attached mail follows:


Hello,

PHP 4.2.2

I'm working on a cart program right now and I can't properly log the
user out. The only way I've been able to get a different session id is
by closing all browser windows and reloading the site.

Scenario:

I go the site I'm working on and click the login page. I have 'echo
session_id();' in the login page so I can see the session id. I fill in
my username and password and click "login". I'm then sent to a
processing page that actually fills in the session variable with some
data (i.e. username, session id, security level, etc.). I then redirect
back to the login page with header("Location: login.php");.

Now that I'm back at the login page I still see my session id (and as
expected it is the same). Then I click "logout" and am taken to a logout
page. The logout page is as follows:

<?
// start the customers session
        session_start();

        session_destroy();
        setcookie("user_info","",(time()-3600),"/");
        header("Location: {$_SERVER["HTTP_REFERER"]}");
        exit;
?>

Here is another version of the same file that I've tried using:

<?
// start the customers session
        session_start();

        session_unset();
        session_destroy();

        header("Location: {$_SERVER["HTTP_REFERER"]}");
        exit;
?>

As far as I have been able to find out (by surveying other people and
RTFM'ing) I'm doing it correctly, but for some it's just not working.

After I click logout I would expect to be sent back to the login page
and see a different session id displayed, but instead I'm presented with
the same session id. The only way I can get a different session id is by
closing all the browser windows and starting over.

Anyone have any ideas?

Thanks,
Chris.

attached mail follows:


You have the same session id, but there is no data in it, so what's the
problem? You should still consider the user logged out since the session is
empty, right?

If you really want, upon logout, make a new session id with session_id(),
md5() and uniqid().

---John Holmes...

----- Original Message -----
From: "Chris W. Parker" <cparkerswatgear.com>
To: <php-generallists.php.net>
Sent: Monday, July 21, 2003 3:28 PM
Subject: [PHP] can't restart session

Hello,

PHP 4.2.2

I'm working on a cart program right now and I can't properly log the
user out. The only way I've been able to get a different session id is
by closing all browser windows and reloading the site.

Scenario:

I go the site I'm working on and click the login page. I have 'echo
session_id();' in the login page so I can see the session id. I fill in
my username and password and click "login". I'm then sent to a
processing page that actually fills in the session variable with some
data (i.e. username, session id, security level, etc.). I then redirect
back to the login page with header("Location: login.php");.

Now that I'm back at the login page I still see my session id (and as
expected it is the same). Then I click "logout" and am taken to a logout
page. The logout page is as follows:

<?
// start the customers session
session_start();

session_destroy();
setcookie("user_info","",(time()-3600),"/");
header("Location: {$_SERVER["HTTP_REFERER"]}");
exit;
?>

Here is another version of the same file that I've tried using:

<?
// start the customers session
session_start();

session_unset();
session_destroy();

header("Location: {$_SERVER["HTTP_REFERER"]}");
exit;
?>

As far as I have been able to find out (by surveying other people and
RTFM'ing) I'm doing it correctly, but for some it's just not working.

After I click logout I would expect to be sent back to the login page
and see a different session id displayed, but instead I'm presented with
the same session id. The only way I can get a different session id is by
closing all the browser windows and starting over.

Anyone have any ideas?

Thanks,
Chris.

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

attached mail follows:


you need to specify what session variables to unset - usually I write a
foreach loop to unset every session variable (unless you are using
certain variables for other parts of the site)

Like This

foreach ($_SESSION as $key => $value){
        session_unregister($key);
}

Chris W. Parker wrote:

> Hello,
>
> PHP 4.2.2
>
> I'm working on a cart program right now and I can't properly log the
> user out. The only way I've been able to get a different session id is
> by closing all browser windows and reloading the site.
>
> Scenario:
>
> I go the site I'm working on and click the login page. I have 'echo
> session_id();' in the login page so I can see the session id. I fill in
> my username and password and click "login". I'm then sent to a
> processing page that actually fills in the session variable with some
> data (i.e. username, session id, security level, etc.). I then redirect
> back to the login page with header("Location: login.php");.
>
> Now that I'm back at the login page I still see my session id (and as
> expected it is the same). Then I click "logout" and am taken to a logout
> page. The logout page is as follows:
>
> <?
> // start the customers session
> session_start();
>
> session_destroy();
> setcookie("user_info","",(time()-3600),"/");
> header("Location: {$_SERVER["HTTP_REFERER"]}");
> exit;
> ?>
>
> Here is another version of the same file that I've tried using:
>
> <?
> // start the customers session
> session_start();
>
> session_unset();
> session_destroy();
>
> header("Location: {$_SERVER["HTTP_REFERER"]}");
> exit;
> ?>
>
>
> As far as I have been able to find out (by surveying other people and
> RTFM'ing) I'm doing it correctly, but for some it's just not working.
>
> After I click logout I would expect to be sent back to the login page
> and see a different session id displayed, but instead I'm presented with
> the same session id. The only way I can get a different session id is by
> closing all the browser windows and starting over.
>
>
> Anyone have any ideas?
>
>
> Thanks,
> Chris.

attached mail follows:


In order to use the set_cookie method to kill a session_id you need to
specify the name of the session, you have used 'user_info' but nowhere in
your code do you specify the session_name("user_info") as the sessions name.

HTH
Ade

-----Original Message-----
From: Chris W. Parker [mailto:cparkerswatgear.com]
Sent: 21 July 2003 20:29
To: php-generallists.php.net
Subject: [PHP] can't restart session

Hello,

PHP 4.2.2

I'm working on a cart program right now and I can't properly log the user
out. The only way I've been able to get a different session id is by closing
all browser windows and reloading the site.

Scenario:

I go the site I'm working on and click the login page. I have 'echo
session_id();' in the login page so I can see the session id. I fill in my
username and password and click "login". I'm then sent to a processing page
that actually fills in the session variable with some data (i.e. username,
session id, security level, etc.). I then redirect back to the login page
with header("Location: login.php");.

Now that I'm back at the login page I still see my session id (and as
expected it is the same). Then I click "logout" and am taken to a logout
page. The logout page is as follows:

<?
// start the customers session
        session_start();

        session_destroy();
        setcookie("user_info","",(time()-3600),"/");
        header("Location: {$_SERVER["HTTP_REFERER"]}");
        exit;
?>

Here is another version of the same file that I've tried using:

<?
// start the customers session
        session_start();

        session_unset();
        session_destroy();

        header("Location: {$_SERVER["HTTP_REFERER"]}");
        exit;
?>

As far as I have been able to find out (by surveying other people and
RTFM'ing) I'm doing it correctly, but for some it's just not working.

After I click logout I would expect to be sent back to the login page and
see a different session id displayed, but instead I'm presented with the
same session id. The only way I can get a different session id is by closing
all the browser windows and starting over.

Anyone have any ideas?

Thanks,
Chris.

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

attached mail follows:


CPT John W. Holmes <mailto:holmes072000charter.net>
    on Monday, July 21, 2003 12:39 PM said:

> You have the same session id, but there is no data in it, so what's
> the problem?

The problem is that the server is still regarding it as the same session
even if a different user comes along and logs in.

> You should still consider the user logged out since the
> session is empty, right?

Right, but the server isn't thinking of it this way.

> If you really want, upon logout, make a new session id with
> session_id(), md5() and uniqid().

This might actually work quite well.

Chris.

attached mail follows:


From: "Chris W. Parker" <cparkerswatgear.com>
> > CPT John W. Holmes <mailto:holmes072000charter.net>
> > on Monday, July 21, 2003 12:39 PM said:
> >
> > You should still consider the user logged out since the
> > session is empty, right?
>
> Right, but the server isn't thinking of it this way.

Then something is wrong in your code. If you properly clear the session of
all of it's contents, then even if I pass the same session id on the next
page request, it should see me as a new user since there is no data in the
session.

---John Holmes...

attached mail follows:


CPT John W. Holmes <mailto:holmes072000charter.net>
    on Monday, July 21, 2003 1:05 PM said:

> Then something is wrong in your code. If you properly clear the
> session of all of it's contents, then even if I pass the same session
> id on the next page request, it should see me as a new user since
> there is no data in the session.

Ok, then maybe I'm misunderstanding how sessions work and/or how they
are supposed to be used.

What is the point of having a unique ID for each session if the only
thing that matters is the data stored within it? Why have a session id
at all if it can't be used to uniquely track a user?

Just for the sake of example, let's say I write the session id to a
database each time someone hits the login page and successfully
authenticates. If the session id doesn't change between each user (using
the same computer, let's say in a public school library) then it would
appear that I've got much less use than I realy do.

Granted someone wouldn't really do it this way but I'm just trying to
make a point.

Chris.

p.s. I'm new to this list as you may have noticed and so far this is the
only list that I've been on that doesn't use the list's address as the
return address. Do I have to manually put it in the To box each time?

attached mail follows:


> p.s. I'm new to this list as you may have noticed and so far this is the
> only list that I've been on that doesn't use the list's address as the
> return address. Do I have to manually put it in the To box each time?

not at all, just use the "reply-all" feature of your mail client.

gabe.

attached mail follows:


> What is the point of having a unique ID for each session if the only
> thing that matters is the data stored within it? Why have a session id
> at all if it can't be used to uniquely track a user?

Well, it can, and it does. I guess it's all in how you use it. If my session
id is "abcd", then when I log out, your program should erase all of the data
in the session and forget that it ever knew about a session called "abcd".
That way, even if I log in with the same session (since the cookie wasn't
deleted, probably, which is probably the cause of this whole problem), then
I will be a new user and not related to the old user/session in any matter.

> p.s. I'm new to this list as you may have noticed and so far this is the
> only list that I've been on that doesn't use the list's address as the
> return address. Do I have to manually put it in the To box each time?

Yeah, the topic of discussion quite a bit in the past few days. Just use the
Reply-All button, please.

---John Holmes...

attached mail follows:


CPT John W. Holmes <mailto:holmes072000charter.net>
    on Monday, July 21, 2003 1:32 PM said:

> Well, it can, and it does. I guess it's all in how you use it. If my
> session id is "abcd", then when I log out, your program should erase
> all of the data in the session and forget that it ever knew about a
> session called "abcd". That way, even if I log in with the same
> session (since the cookie wasn't deleted, probably, which is probably
> the cause of this whole problem), then I will be a new user and not
> related to the old user/session in any matter.

Ok that makes sense. Then in this case, what can you see that I'm doing
wrong that isn't deleting the cookie?

In my first post I showed that one of the versions of the logout page
that I used had this line in it.

setcookie("user_info","",(time()-3600),"/");

Shouldn't that take care of the cookie?

c.

attached mail follows:


> In my first post I showed that one of the versions of the logout page
> that I used had this line in it.
>
> setcookie("user_info","",(time()-3600),"/");
>
> Shouldn't that take care of the cookie?

Like someone else said, that'll take care of a cookie called "user_info".
Your session cookie is named something else, usually PHPSESSID, IIRC.

---John Holmes...

attached mail follows:


Curt, thanks for that, I didnt see that in the notes.

A question that I havent been able to work out since reading this is...

When both you and the person in the contributed notes say: "make your php
cgi setuid" and "that is ran in cgi mode that is setuid'd" ...

How do I setuid a CGI script? ...surely if i access it through the browser
it will still execute as apache?

Cheers

----- Original Message -----
From: "Curt Zirzow" <curtzirzow.dyndns.org>
Newsgroups: php.general
To: <php-generallists.php.net>
Sent: Monday, July 21, 2003 5:08 AM
Subject: Re: [PHP] POSIX seteuid and similar

> * Thus wrote David Goodchild (davidthewishingtree.me.uk):
> > Hi,
> >
> > I am trying to create a small php program where I can control users
> > processes. As far as I see I require Apache to run as root in order to
do
> > this (Note: I wish to access it via a webpage run through a browser). At
> > the moment all pages are executed as user 'apache' (UID #48 in this
case).
> > Other than giving apache root access which i hear is a very bad thing to
do,
> > what other ways can i use the posix_seteuid() functions and the like.
> >
> > Any help at all will be really appreciated.
>
> There is an example in the contributed notes on the site under the
> posix_setuid. Baically it is a perl script that is ran in cgi mode that
> is setuid'd. then opens a php script that runs the setuid script.
>
> I dont see why, if you choose this method is to just bypass the perl cgi
> and just make your php cgi setuid.
>
> I'm not sure of any security issues in doing that but it seems better
> than running your whole apache server as root.
>
> Curt
> --
> "I used to think I was indecisive, but now I'm not so sure."

attached mail follows:


You guys can correct me if I'm wrong but I believe what is referred to
here is SUEXEC.

This allows a virtual domain instance to run as any specified username
and group.

You are not setting the UID of the script but rather any script fun for
that domain. This way you don't have to chmod 777 or chgrp apache
files. The virtual server instance is set to run as you (usually) and
thus has the same permissions you do.

You may have to compile or recompile apache to get this to work for
your set up (requires you specify a path where SUEXEC files exist)
among other things.

hope this helps...

now... any regexp's response out there? :-)

On Monday, July 21, 2003, at 12:56 PM, David Goodchild wrote:

> Curt, thanks for that, I didnt see that in the notes.
>
> A question that I havent been able to work out since reading this is...
>
> When both you and the person in the contributed notes say: "make your
> php
> cgi setuid" and "that is ran in cgi mode that is setuid'd" ...
>
> How do I setuid a CGI script? ...surely if i access it through the
> browser
> it will still execute as apache?
>
> Cheers
>
>
> ----- Original Message -----
> From: "Curt Zirzow" <curtzirzow.dyndns.org>
> Newsgroups: php.general
> To: <php-generallists.php.net>
> Sent: Monday, July 21, 2003 5:08 AM
> Subject: Re: [PHP] POSIX seteuid and similar
>
>
>> * Thus wrote David Goodchild (davidthewishingtree.me.uk):
>>> Hi,
>>>
>>> I am trying to create a small php program where I can control users
>>> processes. As far as I see I require Apache to run as root in order
>>> to
> do
>>> this (Note: I wish to access it via a webpage run through a
>>> browser). At
>>> the moment all pages are executed as user 'apache' (UID #48 in this
> case).
>>> Other than giving apache root access which i hear is a very bad
>>> thing to
> do,
>>> what other ways can i use the posix_seteuid() functions and the like.
>>>
>>> Any help at all will be really appreciated.
>>
>> There is an example in the contributed notes on the site under the
>> posix_setuid. Baically it is a perl script that is ran in cgi mode
>> that
>> is setuid'd. then opens a php script that runs the setuid script.
>>
>> I dont see why, if you choose this method is to just bypass the perl
>> cgi
>> and just make your php cgi setuid.
>>
>> I'm not sure of any security issues in doing that but it seems better
>> than running your whole apache server as root.
>>
>> Curt
>> --
>> "I used to think I was indecisive, but now I'm not so sure."
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

attached mail follows:


Hello,

I have an upload form that will be used for some really large files. I need to ask a couple of questions about the ways of improving the success rate that I have using it.

(1) what is the best and most stable method for uploading a large file. Sometimes the transfer peters out.

(2) how can I get the status of this process? I need to display a percentage uploaded, or a ASCII progress bar, or a progress of some sort. The current form just leaves a user wondering if his browser has crashed or something. Will I need to trigger a repeat loop in a pop-up that checks filesize and displays it?

comments, snippets, ideas? TIA

attached mail follows:


> I have an upload form that will be used for some really large files. I
need to ask a couple of questions about the ways of improving the success
rate that I have using it.
>
> (1) what is the best and most stable method for uploading a large file.
Sometimes the transfer peters out.
>
> (2) how can I get the status of this process? I need to display a
percentage uploaded, or a ASCII progress bar, or a progress of some sort.
The current form just leaves a user wondering if his browser has crashed or
something. Will I need to trigger a repeat loop in a pop-up that checks
filesize and displays it?

Use FTP. You don't get any features with HTML upload.

---John Holmes...

attached mail follows:


* Thus wrote Ivo Fokkema (I.F.A.C.FokkemaLUMC.nl):
> I want to warn you though, PHP depricates the use of register_globals = On,
> so it would be recommendable to use your modified script and keep coding
> using $_POST, $_GET and these kind of global variables.

So php is removing that feature?
 

Curt
--
"I used to think I was indecisive, but now I'm not so sure."

attached mail follows:


* Thus wrote Jiøí Nìmec (konferencemenea.cz):
>
> and I need only first row of each component order by type. so:
>
> cooler aa1317 f
> cpu cpu177 f
> gk NULL i
> mb mb1111 f
> ram me1112 f
>
> has somebody some idea hot to select?

Suggestion: invest in a SQL book.

Curt
--
"I used to think I was indecisive, but now I'm not so sure."

attached mail follows:


* Thus wrote electroteque (danielelectroteque.org):
> hi there my next project at work is to build an ad server for both image and
> flash , i am storing each ad entry into a banner_ads table then another
> table media to store each of the banners into which links to the banner ,
> although in the created admin tool i allow for multiple uploads so a flash
> file can be uploaded for the banner entry and a animated gif version can
> also be uploaded for the banner entry , or just an animated gif banner
> version , ok so when i select for a banner with a start and end date range
> which is valid and is to be shown on a selected site id i grab the files
> associated with it which are the flash and image, so in my while loop i end
> up with to rows of results how would it be possible to display this and how
> am i able to tell if the banner is a flash file with the animated gif
> version of if the banner is just an animated gif and display it differently
> ? let me know thankyou

I have no clue what you just said.

Curt
--
"I used to think I was indecisive, but now I'm not so sure."

attached mail follows:


* Thus wrote stfmoreau (stfmoreauyahoo.fr):
> (ii) Even better:
>
> // _GET
> if (isset($_GET))
> extract($_GET);

Cool.. ya learn somthing every day... thanks..

Curt
--
"I used to think I was indecisive, but now I'm not so sure."

attached mail follows:


What is your aim?

a) to have the site *work* on a server with rg off, or;

b) to re-engineer your site to be safer and more secure, taking
advantage of the REASONS rg was turned off by default?

If it's a, then look at my example on weberdev, or just switch them
back on with something like a .htaccess file.

http://www.weberdev.com/get_example.php3?count=3639

If it's b, then I hope your code is well organised and documented,
because it's a lot of work... I've done it on a few of my sites, but
they were all < 200 scripts.

1. you need to recognise which GET variables are being used in which
scripts, then perform a search & replace. Eg replace all instances of
$page with $_GET['page'], then test test test to see if everything
still works.

2. do the same for POST variables (little easier, because you can view
the contents of your forms to get a list -- if you haven't got it all
documented somewhere).

3. review your session code (hopefully it's one include file, not 100's
of files), replacing your old style code:

<?
$foo = 'bah';
session_register('foo');
// etc
?>

with

<?
$_SESSION['foo'] = 'bah';
// etc
?>

Then find all occurrences of $foo and replace it with $_SESSION['foo'],
etc etc.

Test test test.

4. Review your cookies implementation (if any), and replace all your
$cookieVars with $_COOKIE['cookieVars'].

Test test test.

That's the four biggest areas to worry about. I ended up re-writing my
session code from scratch, and wasn't using cookies (other than session
ones), so it was a relatively pain-free job, especially with a good
search/replace text editor doing most o the work for me.

I can also recommend doing a back-up of the entire site first, and
turning off register globals before you start. So that you're testing
the 'broken' code from day 1.

Good luck!

Justin

On Monday, July 21, 2003, at 10:17 PM, Daryl Meese wrote:

> I would like to rewrite my scripts to work when register globals is
> off.
> The problem is that my scripts encompass several thousand files. Does
> anyone have any suggestions for an effective tool to help in this
> process?
>
> Daryl Meese
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> ---
> [This E-mail scanned for viruses]
>
>

attached mail follows:


* Thus wrote Ford, Mike [LSS] (M.Fordlmu.ac.uk):
> > -----Original Message-----
> > From: Adam Voigt [mailto:adamcryptocomm.com]
> > Sent: 21 July 2003 14:29
> >
> > echo(date('U',strtotime('next Friday')));
>
> Actually, for this upcoming Friday, that'd just be
>
> echo(date('U',strtotime('Friday')));
>
> Slightly confusingly, 'next Friday' would be the Friday after that (because
> 'next' is defined to be equivalent to '2nd' -- no, I don't understand why
> either, I just know it is!!)

Its like when someone tells you to 'take the next exit'.. is it this exit
comming up or the one after that....

Curt
--
"I used to think I was indecisive, but now I'm not so sure."

attached mail follows:


* Thus wrote Adam Voigt (adamcryptocomm.com):
> Umm.
>
> echo(date('U',strtotime('next Friday')));

I prefer:

while(1) echo(date('U', strtotime('Saturday'));
 

Curt
--
"I used to think I was indecisive, but now I'm not so sure."

attached mail follows:


... I agree with everyone else... if you want, you can make a function with
switch... but there's no point really...

<3F1C7273.000003.01112sw032.SOLUTIONSWAVE.COM>
Haseeb:
> hi,
> i have heard a lot of people commenting about the coding style of
> other programmers. i think everyone has his own style. but i also say
> that there should be a standard that should be followed by everyone.
> i know that there are many good tutorials that explain how to code.
> anyway i have my own style. i like keeping all the functions in one
> file and the include the file whenever i need any function. now there
> are few problems in that. i prefer writing functions for almost
> everything sometimes the functions file grows to over 5,000 lines.
> now this is not good. when ever i need one simple function i had to
> include all the file. now i also don't like keeping functions in
> every file that uses it. this is becoming a big problem for me. also
> i have seen some programmer that prefer to use only one file as front
> end and place switch or if conditions and include other files
> depending on the condition. i think its good way of doing things but
> when the magnitude of the projects grows i find it very difficult for
> me to keep working. i find it very hard to concentrate.
>
> this is the problem, i have thought of the solution i.e. divide the
> functions into files. and then include only that file that has the
> function. but i thought i would ask you people how you handle this.
> may be i would find something that suits me more then this solution.
>
> thanx in advance.
> Haseeb
>
>
> ____________________________________________________
> IncrediMail - Email has finally evolved - Click Here

attached mail follows:


ComexEP <mailto:ngxemoc.cjb.net>
    on Monday, July 21, 2003 1:48 PM said:

>> this is the problem, i have thought of the solution i.e. divide the
>> functions into files. and then include only that file that has the
>> function. but i thought i would ask you people how you handle this.
>> may be i would find something that suits me more then this solution.

Hey sorry I just joined this list and I don't think I have seen the
original post so I'm just responding to a response.

Haseeb,

Certain things have to do with programming style, other things are just
bad practice.

Here is an example of coding style:

V1:
function additself($number) {
        return $number += $number;
}

V2:
function additself($number)
{
        return $number += $number;
}

Personally I prefer V4.

Now let's talk about bad practice.

It's bad practice to do what you used to do. That is, to have one huge
file that contains ALL your functions and objects/classes that will ever
be used in your program. To find out just *how* bad it is you can test
the time it takes to include that file using microtime().

Then, after you've split up the file, do the same test and see how much
quicker it is to include three small files than it is to include one
huge file.

You should split up your files by purpose and not by which page they are
included in.

For example, let's say your building an ecommerce store from the ground
up. You'll likely have some functions that perform certain tasks. i.e.
accessing the database, managing your cart, managing users.

Don't be tempted to create different include files for all the different
pages in your cart. Just group them by function/purpose and include only
the files necessary.

Sure it may cause a litle more overhead than if you created include
files specific to each page, but in the long run it will be much less
overhead than if you included everything in every page.

Hope this helps,

Chris.

p.s. I'd appreciate any comments on what I've said that can help improve
my method.

attached mail follows:


<001BD19C96E6E64E8750D72C2EA0ECEE2B7DA7ati-ex-01.ati.local>
Chris W. Parker:
> ComexEP <mailto:ngxemoc.cjb.net>
> on Monday, July 21, 2003 1:48 PM said:
>
>>> this is the problem, i have thought of the solution i.e. divide the
>>> functions into files. and then include only that file that has the
>>> function. but i thought i would ask you people how you handle this.
>>> may be i would find something that suits me more then this solution.
>
> Hey sorry I just joined this list and I don't think I have seen the
> original post so I'm just responding to a response.

_____hi,
i have heard a lot of people commenting about the coding style of other
programmers. i think everyone has his own style. but i also say that there
should be a standard that should be followed by everyone. i know that there
are many good tutorials that explain how to code. anyway i have my own
style. i like keeping all the functions in one file and the include the file
whenever i need any function. now there are few problems in that. i prefer
writing functions for almost everything sometimes the functions file grows
to over 5,000 lines. now this is not good. when ever i need one simple
function i had to include all the file. now i also don't like keeping
functions in every file that uses it. this is becoming a big problem for me.
also i have seen some programmer that prefer to use only one file as front
end and place switch or if conditions and include other files depending on
the condition. i think its good way of doing things but when the magnitude
of the projects grows i find it very difficult for me to keep working. i
find it very hard to concentrate.

this is the problem, i have thought of the solution i.e. divide the
functions into files. and then include only that file that has the function.
but i thought i would ask you people how you handle this. may be i would
find something that suits me more then this solution.

thanx in advance.
Haseeb

_______________________________________________

>
> Haseeb,
>
> Certain things have to do with programming style, other things are
> just bad practice.
>
> Here is an example of coding style:
>
> V1:
> function additself($number) {
> return $number += $number;
> }
>
> V2:
> function additself($number)
> {
> return $number += $number;
> }

Or just return $number + $number;

>
> Personally I prefer V4.

??

>
> Now let's talk about bad practice.
>
> It's bad practice to do what you used to do. That is, to have one huge
> file that contains ALL your functions and objects/classes that will
> ever be used in your program. To find out just *how* bad it is you
> can test the time it takes to include that file using microtime().
>
> Then, after you've split up the file, do the same test and see how
> much quicker it is to include three small files than it is to include
> one huge file.
>
> You should split up your files by purpose and not by which page they
> are included in.
>
> For example, let's say your building an ecommerce store from the
> ground up. You'll likely have some functions that perform certain
> tasks. i.e. accessing the database, managing your cart, managing
> users.
>
> Don't be tempted to create different include files for all the
> different pages in your cart. Just group them by function/purpose and
> include only the files necessary.
>
> Sure it may cause a litle more overhead than if you created include
> files specific to each page, but in the long run it will be much less
> overhead than if you included everything in every page.
>
> Hope this helps,
>
>
> Chris.
>
> p.s. I'd appreciate any comments on what I've said that can help
> improve my method.

attached mail follows:


>
> <3F1C7273.000003.01112sw032.SOLUTIONSWAVE.COM>
> Haseeb:
>> hi,
>> i have heard a lot of people commenting about the coding style of
>> other programmers. i think everyone has his own style.

>> but i also say
>> that there should be a standard that should be followed by everyone.

A nice idea that can never fly. It might work for basic programming
but you have to realize there are many ways and styles that people
develop - often times based on their idea of "proper" coding
philosophy. OO code is a perfect case in point. Pure OO coders (the
ones that realize Small Talk is the ideal OO model *shrug*) will have a
different style and implementation. This thread talks about using
include files (and thus classes) as a good way to split up code. The
problem is, the code i've seen, the reason for using the classes isn't
to write any object code at all (where is the inheritance?) but rather
to keep thing organized. PHP suffers from the fact that there is a
huge difference between the most basic of programming skills (it's an
easy language to pick up) and the folks that have been writing OO code
all their life (C++, Perl, Java, etc.). I've seen it in Perl - I
cannot code in the same style as a friend of mine (Randal Schwartz).
He simply thinks on a much higher level than I ever will and thus his
coding style will always be more sophisticated.

Just my two cents...

attached mail follows:


In making an array:

I have 7 checkboxes, which make up the array information. I currently use
implode to make the array, however that array only consists of the
information that it checked.

What I need to do now is make it so the array will always be 7 items, but if
there isnt a checkbox for the item, I want inserted to be a 0.

Example

item1[x]
item2[x]
item3[ ]
item4[x]
item5[ ]
item6[x]
item7[ ]

would return = 1,2,0,4,0,6,0

instead of what it does now. 1,2,4,6

I tried placing in the lines before the implode command, saying that:

if($array[0]=="") { $array[0]="0"; } else { }
if($array[1]=="") { $array[1]="0"; } else { }
if($array[2]=="") { $array[2]="0"; } else { }
if($array[3]=="") { $array[3]="0"; } else { }
if($array[4]=="") { $array[4]="0"; } else { }
if($array[5]=="") { $array[5]="0"; } else { }
if($array[6]=="") { $array[6]="0"; } else { }

But this just made the values of the array become blank.

Any suggestions?

Thanks in advance,

Phillip

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.501 / Virus Database: 299 - Release Date: 7/14/2003

attached mail follows:


> I have 7 checkboxes, which make up the array information. I currently use
> implode to make the array, however that array only consists of the
> information that it checked.
>
> What I need to do now is make it so the array will always be 7 items, but
if
> there isnt a checkbox for the item, I want inserted to be a 0.

You could name the checkboxes such as

<input type="checkbox" name="item[0]" value="0">
<input type="checkbox" name="item[1]" value="1">
etc...

Then, since you know you have 7 boxes

for($x=0;$x<7;$x++)
{ $final_array[$x] = isset($_GET['item'][$x]) ? $_GET['item'][$x] : 0; }

or

$ar = array_fill(0,7,0);
$final_array = $_GET['item'] + $ar;

---John Holmes...

attached mail follows:


I'm trying to connect to a oracle database using the " Microsoft ODBC for
Oracle " driver with the
followin script:

<?php
     $user= "user";
     $upasswd="password";
     $dsn = "dsn";
    $query = "select sysdate from dual";
    $conn = odbc_pconnect($dsn, $user,$upasswd );
    if (!$conn)
       { print "Connection failed\n</html>";
        exit;
        }
    if ($result = odbc_Exec($conn, $query))
    { print "Query returned : " . odbc_num_rows($result) . " rows";
    odbc_result_all($result, "border = 1"); }
  ?>

And received the following error:
Warning: SQL error: [Microsoft][ODBC driver for Oracle][Oracle]ORA-12154:
TNS:could not resolve
service name, SQL state 08001 in SQLConnect in c:\php\files\p.php on line 6

Can any body help With this error.

Wha i have to set for connecting with oracle using odbc?

Regards,

Angel M.S.F.

attached mail follows:


    Hi,

    I have PHP 4.3.1 and PostgreSQL 7.3 running in a Mandrake 9.1
workstation. When trying to connect to the DB, the PHP execution just
blocks in pg_connect() call, and it remain blocked for several minutes -
until I cancel the request. Sometimes the call completes, but I am not
sure it connected sucessfully (did not execute any query).
    Postmaster is running with "-i" option and acess permitions are OK.
There is no error message at all.

                                                                                                                              Any
help?

                                                                                                                                           Nelson

attached mail follows:


I've got a strange request, maybe one of the experts here can help?

I need to be able to take a mail message on stdin, bust it up into headers,
and the constituent mime-parts if any, and be able to parse the headers,
and get at any
text/plain (or only) part, and shove the headers and
text/plain into a database.

I really don't feel like reinventing the wheel on the mime side.

PHP 4.3.x, if it matters.

Thanks!

LER

--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: lerlerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749

attached mail follows:


There are classes built into PEAR that handle that

Larry Rosenman wrote:

> I've got a strange request, maybe one of the experts here can help?
>
> I need to be able to take a mail message on stdin, bust it up into
> headers, and the constituent mime-parts if any, and be able to parse the
> headers, and get at any
> text/plain (or only) part, and shove the headers and
> text/plain into a database.
>
> I really don't feel like reinventing the wheel on the mime side.
>
> PHP 4.3.x, if it matters.
>
> Thanks!
>
> LER
>
>

attached mail follows:


There are classes built into PEAR that handle that

Larry Rosenman wrote:

> I've got a strange request, maybe one of the experts here can help?
>
> I need to be able to take a mail message on stdin, bust it up into
> headers, and the constituent mime-parts if any, and be able to parse the
> headers, and get at any
> text/plain (or only) part, and shove the headers and
> text/plain into a database.
>
> I really don't feel like reinventing the wheel on the mime side.
>
> PHP 4.3.x, if it matters.
>
> Thanks!
>
> LER
>
>

attached mail follows:


Hardik Doshi wrote:
> There is still one problem. On so many forms on my
> education intranet application, students are
> submitting the final projects with the supporting
> documents and images. Once they submit the final
> project, my script is performing serveral error
> checking for the file size, extension etc. What should
> i have to do for those kind of stuff? Because if
> someone submits a very large file then my script won't
> be able to upload the file (because of PHP file upload
> limit set into the php.ini)

Well, you can't do anything about a very large file except increasing
the size in php.ini.

As for them being logged off and then submitting a file, you'll handle
it the same way. Upon realizing the session is invalid, but a file has
been submitted, you save that file in another temp folder and save the
information in the session. Upon correct revalidation, you load the
information for the file back into $_FILES, the form information back
into $_POST, and then run the original page that was reqested.

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A magazine for PHP Professionals – www.phparch.com

attached mail follows:


I've noticed in the PHP docs "EXPERIMENTAL" is marked over all the
socket functions. Would it be risky to develop a PHP socket app using
those functions? It seems they could change with the next release and
my app would instantly stop working.

On the other hand, I've found a lot of tutorials extolling PHP's socket
functions, and since I know PHP a bit now I would rather use it for my
TCP socket application than learn C and implement it there.

What do you think?

...Rene

attached mail follows:


* Thus wrote René Fournier (renesmartslitters.com):
> I've noticed in the PHP docs "EXPERIMENTAL" is marked over all the
> socket functions. Would it be risky to develop a PHP socket app using
> those functions? It seems they could change with the next release and
> my app would instantly stop working.

I wouldn't use it on any live site.

>
> On the other hand, I've found a lot of tutorials extolling PHP's socket
> functions, and since I know PHP a bit now I would rather use it for my
> TCP socket application than learn C and implement it there.
>
> What do you think?

if you plan on using it, it might be wise to get on the php-dev mailing
list and watch stuff there too. And maybe talk to the people who are
writing the socket extension.

Curt
--
"I used to think I was indecisive, but now I'm not so sure."

attached mail follows:


--- Curt Zirzow <curtzirzow.dyndns.org> wrote:
> > On the other hand, I've found a lot of tutorials extolling PHP's
> > socket functions, and since I know PHP a bit now I would rather
> > use it for my TCP socket application than learn C and implement
> > it there.
> >
> > What do you think?
>
> if you plan on using it, it might be wise to get on the php-dev
> mailing list and watch stuff there too. And maybe talk to the
> people who are writing the socket extension.

Disclaimer: Things listed as experimental should always be treated as such and
never relied upon to have a consistent API or not break.

That said, I recall that the current sockets extension maintainer desires to
label the extension stable as soon as possible. This means that it is highly
unlikely that the API will change. In addition, I have used it extensively and
have found it to be very stable under a number of conditions. I treat it as a
stable extension myself.

Chris

=====
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/

attached mail follows:


* Thus wrote Chris Shiflett (shiflettphp.net):
>
> Disclaimer: Things listed as experimental should always be treated as such and
> never relied upon to have a consistent API or not break.
>
> That said, I recall that the current sockets extension maintainer desires to
> label the extension stable as soon as possible. This means that it is highly
> unlikely that the API will change. In addition, I have used it extensively and
> have found it to be very stable under a number of conditions. I treat it as a
> stable extension myself.

Thats good to hear.. thanks.

Curt
--
"I used to think I was indecisive, but now I'm not so sure."

attached mail follows:


Can someone direct me as to how to install PHP on a linux system as CGI? I
wish to attempt to use posix_setuid() functions.

Thanks

attached mail follows:


In article <20030721222016.82215.qmailpb1.pair.com>,
davidthewishingtree.me.uk says...
> Can someone direct me as to how to install PHP on a linux system as CGI? I
> wish to attempt to use posix_setuid() functions.
>
> Thanks

If you are compiling from source, use your normal configure but without
reference to --with-apxs and a binary executable will be created. If you
are using 4.3 I think there is a php-cli which should do what you want.

--
Quod subigo farinam

attached mail follows:


Is there a way to get fsockopen to suppress the header information it
returns. I have no use for the crap, have no idea how to use a regexp
to get it out of there (nor does anyone on this list it would seem
either).

I'd like to be able to grab a web page as it is presented to the
browsers (as seen in view source).

HTTP/1.1 200 OK
Date: Tue, 22 Jul 2003 05:14:41 GMT
Server: Apache/1.3.27 (Unix) mod_jk/1.1.0 mod_ssl/2.8.12 OpenSSL/0.9.6g
Set-Cookie: JSESSIONID=jwjesefa81;Path=/Interface
Connection: close
Content-Type: text/html;charset=ISO-8859-1

The above crap needs to not be returned.

Any ideas?

attached mail follows:


* Thus wrote Doug La Farge (douglafarge.net):
> Is there a way to get fsockopen to suppress the header information it
> returns. I have no use for the crap, have no idea how to use a regexp
> to get it out of there (nor does anyone on this list it would seem
> either).

I have plenty of use for the so called 'crap'. I know how to use a
regex to strip it out of there, and your using the *wrong* function.

RTFM...
(no link provided)

>
>
> I'd like to be able to grab a web page as it is presented to the
> browsers (as seen in view source).

That is not how it is presented to the browser. The browser presents to
you something entirely different.

>
> HTTP/1.1 200 OK
> Date: Tue, 22 Jul 2003 05:14:41 GMT
> Server: Apache/1.3.27 (Unix) mod_jk/1.1.0 mod_ssl/2.8.12 OpenSSL/0.9.6g
> Set-Cookie: JSESSIONID=jwjesefa81;Path=/Interface
> Connection: close
> Content-Type: text/html;charset=ISO-8859-1
>
> The above crap needs to not be returned.

Yes it does.

>
> Any ideas?

Of course.

Curt
--
"I used to think I was indecisive, but now I'm not so sure."

attached mail follows:


When using the backtick operator:

$rsh = split("\n", `rsh 10.0.0.2 sysstat -c 5 -xs 5 2>&1 </dev/null`);

I get the following defunct (zombie) processes

root 1477 0.0 0.2 1608 604 ? S 15:44 0:00 \_ CROND
nagios 1478 0.1 0.3 1964 864 ? S 15:44 0:00 \_
/bin/sh -c /usr/local/bin/php /home/jeff/at.php 1>/dev/null 2>&1
nagios 1484 0.7 1.2 6416 3176 ? S 15:44 0:00 \_
/usr/local/bin/php /home/jeff/at.php
nagios 1537 0.0 0.3 1952 848 ? S 15:44 0:00
 \_ sh -c rsh 10.0.0.2 sysstat -c 5 -xs 5 2>&1 </dev/null
nagios 1545 0.1 0.3 1844 772 ? S 15:44 0:00
     \_ rsh 10.0.0.2 sysstat -c 5 -xs 5
nagios 1564 0.0 0.0 0 0 ? Z 15:44 0:00
         \_ [rsh <defunct>]

Any thoughts?
Jeff
phpgurugeek.com

attached mail follows:


I've built a CSV parser that I want to run on every file in a folder. How
do I do this?

attached mail follows:


* Thus wrote jwulff (johnworcasnet.com):
> I've built a CSV parser that I want to run on every file in a folder. How
> do I do this?

For starters, no sense in re-inventing the wheel:
  http://php.net/fgetcsv

Second :
  htt