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 20 Oct 2004 20:12:36 -0000 Issue 3064

php-general-digest-helplists.php.net
Date: Wed Oct 20 2004 - 15:12:36 CDT


php-general Digest 20 Oct 2004 20:12:36 -0000 Issue 3064

Topics (messages 199854 through 199939):

Re: str_replace problem
        199854 by: Silvio Porcellana
        199862 by: Robin Vickery
        199890 by: Philip Thompson
        199934 by: Chris Ditty

Re: File Copy
        199855 by: Silvio Porcellana
        199856 by: Aidal
        199857 by: M. Sokolewicz
        199858 by: Aidal
        199859 by: Chris Dowell
        199860 by: Silvio Porcellana
        199869 by: Dusty Bin
        199870 by: Dusty Bin
        199872 by: Dusty Bin

Re: CPU usage 5% during 2 minutes
        199861 by: Marek Kilimajer
        199863 by: Janke Dávid
        199873 by: Janke Dávid
        199891 by: Greg Donald

1st day of the Week
        199864 by: Shaun
        199866 by: Ford, Mike

Re: Mixing classes
        199865 by: Tomi Kaistila
        199882 by: Greg Donald
        199894 by: Bruno B B Magalhães
        199896 by: Bruno B B Magalhães
        199922 by: Tomi Kaistila

change server unix->win
        199867 by: Patrick Fehr
        199868 by: Robert Cummings
        199888 by: Greg Donald
        199893 by: Francisco M. Marzoa Alonso

Validation problem with array.
        199871 by: Stuart Felenstein
        199874 by: Graham Cossey
        199875 by: Stuart Felenstein
        199877 by: Graham Cossey
        199878 by: Stuart Felenstein
        199879 by: Brent Baisley
        199880 by: Stuart Felenstein
        199885 by: Brent Baisley
        199886 by: Stuart Felenstein

Re: permission for file creating script
        199876 by: John Nichel

relative paths with "require"
        199881 by: Joey Morwick
        199884 by: Greg Donald
        199895 by: Joey Morwick

Re: Automatic Form processor
        199883 by: Dan Joseph

Re: CPU usage 5% during 2 minutes SOLVED
        199887 by: Janke Dávid
        199892 by: Matt M.

Re: Nesting level too deep - recursive dependency?
        199889 by: Curt Zirzow

wrapper
        199897 by: Stanislav Kuhn

remote file existance when protected by a .htaccess
        199898 by: Mag
        199901 by: Matt M.

fopen by URL is disabled, is there another way of reading a remote webpage?
        199899 by: Chuck Barnett
        199900 by: Greg Donald
        199918 by: Jennifer Goodie
        199921 by: Vail, Warren

Re: fputcsv() error message
        199902 by: Pablo Gosse
        199906 by: Steven
        199909 by: Greg Donald

Regexp help
        199903 by: Chris Boget
        199925 by: John Holmes

parsing a string
        199904 by: Dan McCullough
        199905 by: Greg Beaver
        199907 by: M. Sokolewicz
        199923 by: Dan McCullough
        199932 by: Dan McCullough

PHP on Windows
        199908 by: Jonathan Haddad
        199910 by: Greg Donald
        199911 by: Jay Blanchard
        199913 by: bbonkosk.tampabay.rr.com
        199914 by: Jonel Rienton

url
        199912 by: Dan McCullough
        199915 by: John Nichel
        199916 by: Neal Carmine
        199917 by: Greg Donald
        199919 by: Mike Smith
        199920 by: Janet Valade

heredoc syntax
        199924 by: Adil
        199926 by: M. Sokolewicz
        199928 by: Janet Valade
        199935 by: Matthew Weier O'Phinney
        199936 by: Matthew Weier O'Phinney
        199938 by: Rory Browne

Problem with php 4/5, segmentation fault
        199927 by: robert mena

Re: Best way to allow a user to indicate formatting to be displayed but stored.
        199929 by: GH
        199930 by: Greg Donald
        199931 by: Marek Kilimajer

Send variable in include()
        199933 by: Pete
        199937 by: John Nichel

Mac OS X and Editor
        199939 by: Jonel Rienton

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:


Chris Ditty wrote:
> Hi all. I'm trying to do a little code snippets page for a site I am
> working on. I figured it would be simple enough. I would do a
> str_replace and replace the various html codes with the ascii
> eqivulant. Unfortunately, it is not working as expected. Can anyone
> help with this?
>
What is that you are actually expecting?

> This is what I am using.
> $snippetCode = str_replace("\n", "<br>", $snippet['snippetCode']);
nl2br() [http://php.libero.it/manual/en/function.nl2br.php]

> $snippetCode = str_replace("<", "&gt;", $snippetCode);
> $snippetCode = str_replace(">", "&lt;", $snippetCode);
> $snippetCode = str_replace("&", "&amp;", $snippetCode);
>
> This is what is in $snippet['snippetCode'].
> ?><pre><? print_r($ArrayName); ?></pre><?
>
> This is what is showing on the web page.
> ?&lt;&gt;pre&lt;&gt;? print_r($ArrayName); ?&lt;&gt;/pre&lt;&gt;?
>
This is what you are asking PHP to do.
Actually - to achieve this - it would be better to use the 'htmlspecialchars()' function
[http://php.libero.it/manual/en/function.htmlspecialchars.php]

Anyway, probably I didn't understand what you want from your code...

Cheers!
Silvio Porcellana

attached mail follows:


On Wed, 20 Oct 2004 01:02:12 -0500, Chris Ditty <cdittygmail.com> wrote:
> Hi all. I'm trying to do a little code snippets page for a site I am
> working on. I figured it would be simple enough. I would do a
> str_replace and replace the various html codes with the ascii
> eqivulant. Unfortunately, it is not working as expected. Can anyone
> help with this?
>
> This is what I am using.
> $snippetCode = str_replace("\n", "<br>", $snippet['snippetCode']);
> $snippetCode = str_replace("<", "&gt;", $snippetCode);
> $snippetCode = str_replace(">", "&lt;", $snippetCode);
> $snippetCode = str_replace("&", "&amp;", $snippetCode);
>
> This is what is in $snippet['snippetCode'].
> ?><pre><? print_r($ArrayName); ?></pre><?
>
> This is what is showing on the web page.
> ?&lt;&gt;pre&lt;&gt;? print_r($ArrayName); ?&lt;&gt;/pre&lt;&gt;?

Ok, first off there are builtin functions to do this kind of thing:

  http://www.php.net/htmlspecialchars
  http://www.php.net/nl2br

Secondly, think about what your code is doing, and the order that it's
doing the replacements.

The first thing you're doing is replacing the newlines with <br> tags.

The second and third things you're doing will disable all the tags
including the <br> tags you've just inserted, by replacing '<' with
&lt; and '> with &gt html entities;

The fourth thing you're doing is disabling the html entities by
replacing '&' with &amp; including the entities you've just inserted
as steps two and three.

  -robin

attached mail follows:


On Oct 20, 2004, at 1:02 AM, Chris Ditty wrote:

> Hi all. I'm trying to do a little code snippets page for a site I am
> working on. I figured it would be simple enough. I would do a
> str_replace and replace the various html codes with the ascii
> eqivulant. Unfortunately, it is not working as expected. Can anyone
> help with this?
>
> This is what I am using.
> $snippetCode = str_replace("\n", "<br>", $snippet['snippetCode']);
> $snippetCode = str_replace("<", "&gt;", $snippetCode);

< is actually less than

> $snippetCode = str_replace(">", "&lt;", $snippetCode);

and > is greater than. Don't know if this makes a difference to you.

> $snippetCode = str_replace("&", "&amp;", $snippetCode);
>
> This is what is in $snippet['snippetCode'].
> ?><pre><? print_r($ArrayName); ?></pre><?
>
> This is what is showing on the web page.
> ?&lt;&gt;pre&lt;&gt;? print_r($ArrayName); ?&lt;&gt;/pre&lt;&gt;?
>
> If anyone can help, it would be appreciated. Also, if you have a
> quick and dirty code colorer, I would appreciate that.
>
> Thanks
> Chris

Like the others have said, consider using htmlspecialchars().

Have fun!
~Philip

attached mail follows:


Thanks all for the tips. Was able to get it working like I wanted.

Chris

attached mail follows:


Aidal wrote:
> Hi NG.
>
> I'm experiencing some problems when trying to copy a file from one location
> to another on the web server.
>
> example:
>
> dir1/subdir1/some_image_name.jpg --> dir2/subdir2/some_new_image_name.jpg
>
> When I do this the file permissions changes and I'm no longer the owner of
> the file. I tried to use chmod('the_new_file', 0777); but it doesn't work,
> because chmod() wont let me change the permissions since I'm not the owner
> of this new file.
>
The owner should now be the user the Web server is running as.
To change file ownerships you need to use the PHP FTP functions.
Check out these pages: http://php.libero.it/manual/en/ref.ftp.php

HTH, cheers!
Silvio Porcellana

attached mail follows:


ftp_chmod() is part of PHP 5 and I'm working with PHP 4.3.1.

I tried the ftp_raw('CHMOD 777 filename.jpg'); doesn't work either though :(

"Silvio Porcellana" <sporctin.it> wrote in message
news:41761F4A.4050206tin.it...
> Aidal wrote:
> > Hi NG.
> >
> > I'm experiencing some problems when trying to copy a file from one
location
> > to another on the web server.
> >
> > example:
> >
> > dir1/subdir1/some_image_name.jpg -->
dir2/subdir2/some_new_image_name.jpg
> >
> > When I do this the file permissions changes and I'm no longer the owner
of
> > the file. I tried to use chmod('the_new_file', 0777); but it doesn't
work,
> > because chmod() wont let me change the permissions since I'm not the
owner
> > of this new file.
> >
> The owner should now be the user the Web server is running as.
> To change file ownerships you need to use the PHP FTP functions.
> Check out these pages: http://php.libero.it/manual/en/ref.ftp.php
>
> HTH, cheers!
> Silvio Porcellana

attached mail follows:


how about setting the correct umask. Or else su'ing to the correct user
before moving it.

Aidal wrote:
> ftp_chmod() is part of PHP 5 and I'm working with PHP 4.3.1.
>
> I tried the ftp_raw('CHMOD 777 filename.jpg'); doesn't work either though :(
>
> "Silvio Porcellana" <sporctin.it> wrote in message
> news:41761F4A.4050206tin.it...
>
>>Aidal wrote:
>>
>>>Hi NG.
>>>
>>>I'm experiencing some problems when trying to copy a file from one
>
> location
>
>>>to another on the web server.
>>>
>>>example:
>>>
>>>dir1/subdir1/some_image_name.jpg -->
>
> dir2/subdir2/some_new_image_name.jpg
>
>>>When I do this the file permissions changes and I'm no longer the owner
>
> of
>
>>>the file. I tried to use chmod('the_new_file', 0777); but it doesn't
>
> work,
>
>>>because chmod() wont let me change the permissions since I'm not the
>
> owner
>
>>>of this new file.
>>>
>>
>>The owner should now be the user the Web server is running as.
>>To change file ownerships you need to use the PHP FTP functions.
>>Check out these pages: http://php.libero.it/manual/en/ref.ftp.php
>>
>>HTH, cheers!
>>Silvio Porcellana

attached mail follows:


ERR, I meant I tried ftp_exec(), ftp_raw() is a PHP 5 function too...

"Aidal" <adminyellowonline.dk> wrote in message
news:20041020085547.18435.qmailpb1.pair.com...
> ftp_chmod() is part of PHP 5 and I'm working with PHP 4.3.1.
>
> I tried the ftp_raw('CHMOD 777 filename.jpg'); doesn't work either though
:(
>
> "Silvio Porcellana" <sporctin.it> wrote in message
> news:41761F4A.4050206tin.it...
> > Aidal wrote:
> > > Hi NG.
> > >
> > > I'm experiencing some problems when trying to copy a file from one
> location
> > > to another on the web server.
> > >
> > > example:
> > >
> > > dir1/subdir1/some_image_name.jpg -->
> dir2/subdir2/some_new_image_name.jpg
> > >
> > > When I do this the file permissions changes and I'm no longer the
owner
> of
> > > the file. I tried to use chmod('the_new_file', 0777); but it doesn't
> work,
> > > because chmod() wont let me change the permissions since I'm not the
> owner
> > > of this new file.
> > >
> > The owner should now be the user the Web server is running as.
> > To change file ownerships you need to use the PHP FTP functions.
> > Check out these pages: http://php.libero.it/manual/en/ref.ftp.php
> >
> > HTH, cheers!
> > Silvio Porcellana

attached mail follows:


Aidal

Could you post the relevant parts of your code so we have a little
context to work in?

You say you're copying a file from one location to another on the same
server. If this is the case you are very unlikely to be in need of the
ftp family of functions, which are only valid for use over an
established ftp connection.

I suspect that the file is indeed now owned by the webserver

has it changed from aidal:somegroup to nobody:nogroup or something like
that?

Post us some code and the answers you get will probably be more useful

Cheers

Chris

Aidal wrote:
> ftp_chmod() is part of PHP 5 and I'm working with PHP 4.3.1.
>
> I tried the ftp_raw('CHMOD 777 filename.jpg'); doesn't work either though :(
>
> "Silvio Porcellana" <sporctin.it> wrote in message
> news:41761F4A.4050206tin.it...
>
>>Aidal wrote:
>>
>>>Hi NG.
>>>
>>>I'm experiencing some problems when trying to copy a file from one
>
> location
>
>>>to another on the web server.
>>>
>>>example:
>>>
>>>dir1/subdir1/some_image_name.jpg -->
>
> dir2/subdir2/some_new_image_name.jpg
>
>>>When I do this the file permissions changes and I'm no longer the owner
>
> of
>
>>>the file. I tried to use chmod('the_new_file', 0777); but it doesn't
>
> work,
>
>>>because chmod() wont let me change the permissions since I'm not the
>
> owner
>
>>>of this new file.
>>>
>>
>>The owner should now be the user the Web server is running as.
>>To change file ownerships you need to use the PHP FTP functions.
>>Check out these pages: http://php.libero.it/manual/en/ref.ftp.php
>>
>>HTH, cheers!
>>Silvio Porcellana
>
>

attached mail follows:


Chris Dowell wrote:
> Aidal
>
> Could you post the relevant parts of your code so we have a little
> context to work in?
>
> You say you're copying a file from one location to another on the same
> server. If this is the case you are very unlikely to be in need of the
> ftp family of functions, which are only valid for use over an
> established ftp connection.
>
You can indeed establish an FTP connection to your local server - provided it has an FTP
server running.
The files are actually copied by Apache (or whatever Web server he's using), so this is
why the server becomes the owner.

> I suspect that the file is indeed now owned by the webserver
>
> has it changed from aidal:somegroup to nobody:nogroup or something like
> that?
>
I guess this is the problem Aidal is experiencing.

In order to maintain file ownserships, what he can do (since he doesn't have PHP 5) is
"copy" the file with 'ftp_fput()' [http://php.libero.it/manual/en/function.ftp-fput.php].
That is, he opens the files he wants to copy and PUTs it via this function. Since he is
logged in - using 'ftp_connect()' and 'ftp_login()' - the files will be owned by the user
he used to login.

My .2 euros...

Cheers,
Silvio Porcellana

<snip>

attached mail follows:


Aidal,
        presumably, your server had the write to copy the file, otherwise the
copy would have failed. Is the only problem that you don't have the
correct permissions on the copied file?? if so check out
<http://www.php.net/manual/en/function.umask.php>. If you set the umask
before you copy, you should have the correct permissions.

Best regards. . . Dusty
Silvio Porcellana wrote:
> Chris Dowell wrote:
>
>> Aidal
>>
>> Could you post the relevant parts of your code so we have a little
>> context to work in?
>>
>> You say you're copying a file from one location to another on the same
>> server. If this is the case you are very unlikely to be in need of the
>> ftp family of functions, which are only valid for use over an
>> established ftp connection.
>>
> You can indeed establish an FTP connection to your local server -
> provided it has an FTP server running.
> The files are actually copied by Apache (or whatever Web server he's
> using), so this is why the server becomes the owner.
>
>> I suspect that the file is indeed now owned by the webserver
>>
>> has it changed from aidal:somegroup to nobody:nogroup or something
>> like that?
>>
> I guess this is the problem Aidal is experiencing.
>
> In order to maintain file ownserships, what he can do (since he doesn't
> have PHP 5) is "copy" the file with 'ftp_fput()'
> [http://php.libero.it/manual/en/function.ftp-fput.php].
> That is, he opens the files he wants to copy and PUTs it via this
> function. Since he is logged in - using 'ftp_connect()' and
> 'ftp_login()' - the files will be owned by the user he used to login.
>
> My .2 euros...
>
> Cheers,
> Silvio Porcellana
>
> <snip>

attached mail follows:


Aidal,
        I assume that you are using your server to copy the file, and since the
copy apparently suceeds, your server must have read access to the source
file. Check out
<http://www.php.net/manual/en/function.umask.php>. If you set the
correct umask prior to your copy, your copied file should end up with
the correct permissions. Even if it doesn't, you should be able to
chmod correctly. Be careful with the mask, it is set up with negative
logic. If you have access to an *nix system, try a "man umask" for more
information.

Hope this helps. . . Dusty
Aidal wrote:

> Hi NG.
>
> I'm experiencing some problems when trying to copy a file from one location
> to another on the web server.
>
> example:
>
> dir1/subdir1/some_image_name.jpg --> dir2/subdir2/some_new_image_name.jpg
>
> When I do this the file permissions changes and I'm no longer the owner of
> the file. I tried to use chmod('the_new_file', 0777); but it doesn't work,
> because chmod() wont let me change the permissions since I'm not the owner
> of this new file.
>
> The server runs on some kind of UNIX based system...
>
> Any help or suggestions would be much appreciated, thanks.
>
> /Aidal

attached mail follows:


Aidal,
        since you are using the server to copy the file, and the copy succeeds,
the server obviously has at least read access to the source.
You just can't get the permissions right. Check out:
<http://www.php.net/manual/en/function.umask.php>. If you have access
to your server or another *nix machine also check out "man umask". If
you set your umask before the copy, your file should be copied with the
right permissions. If you set the umask after the copy, you should be
able to chmod. Be careful how you set the umask, it's not as straight
forward as is seems.

Hope this helps. . . Dusty
Aidal wrote:

> Hi NG.
>
> I'm experiencing some problems when trying to copy a file from one location
> to another on the web server.
>
> example:
>
> dir1/subdir1/some_image_name.jpg --> dir2/subdir2/some_new_image_name.jpg
>
> When I do this the file permissions changes and I'm no longer the owner of
> the file. I tried to use chmod('the_new_file', 0777); but it doesn't work,
> because chmod() wont let me change the permissions since I'm not the owner
> of this new file.
>
> The server runs on some kind of UNIX based system...
>
> Any help or suggestions would be much appreciated, thanks.
>
> /Aidal

attached mail follows:


Janke Dávid wrote:
> 2004-10-20, sze keltezéssel 00:19-kor Ed Lazor ezt írta:
>
>>>>How any rows are you pulling from the database?
>>>
>>>aprrox. 12.000 but there are only around 50-100 new rows at a maximum
>>>within a day, and there were almost as many before the
>>>problem appeared.
>>
>>You're creating a form with over 12,000 options in a select statement?
>
>
> Unfortunately yes. This is a serial code from a paper form. Because they
> want to be able to select each form individually from on page there is
> no other way.
> (maybe I should implement an archivating function)

What if you try wget to fetch the page? Is the script still running slow?

attached mail follows:


2004-10-20, sze keltezéssel 00:19-kor Ed Lazor ezt írta:
> > >How any rows are you pulling from the database?
> > aprrox. 12.000 but there are only around 50-100 new rows at a
maximum
> > within a day, and there were almost as many before the
> > problem appeared.
>
> You're creating a form with over 12,000 options in a select statement?

Unfortunately yes. This is a serial code from a paper form. Because they
want to be able to select each form individually from on page there is
no other way.
(maybe I should implement an archivating function)

> Have you tried to increase the amount of memory available to this
script?

Yes.
I have set it to 64M, but it didn't seem to work.
It is strange, that now I have set it to -1 (according to the php doc
this is the value for unlimited memory access). Now it is faster. But by
now I can't say how fast it really is. The customer will say it
tomorrow.

Thanks very much for the help by now

attached mail follows:


HEEEEEEEEEEEEEEEEEEEEEEEELP!

This becomes more and more strange. Aftar I was really happy, that the
code runs fast again, the customer sent an e-mail that is still slow.
So I logged in into his network and everything was ok for me, but when
they tried to use the program, I still saw (using top), that the CPU
usage is still 5% (highest value).
So I began to use the debug log of apache, and see what happened (LOOK
AT THE LAST NUMBER, WHICH SHOWS HOW LONG THE SCRIPT RUN):

In this case I was using it from the localhost:
10.36.0.5 - - [20/Oct/2004:14:27:25 +0200] "GET
/form.php?op=reprint_form_sel HTTP/1.1" 200 1478211 "-" "Links (0.99;
Linux 2.6.8-1-686 i686; 80x24)" 17970 3

In this case I was using it from another host in the network (actually
the proxy):
10.36.0.2 - - [20/Oct/2004:14:23:33 +0200] "GET
/bizerba/form.php?op=select_form HTTP/1.0" 200 1473492 "-"
"Lynx/2.8.5rel.1 libwww-FM/2.14
SSL-MM/1.4.1 GNUTLS/0.8.12" 17969 7

In this case the some other client was using it from the network:
10.36.0.2 - - [20/Oct/2004:14:33:23 +0200] "GET
/bizerba/form.php?op=select_form HTTP/1.0" 200 1473492 "-" "Mozilla/4.0
(compatible; MSIE 6.0; Windows NT 5.1)" 17970 36

No, it is not the network, which is slow!

Is it possible, that all clients (except me) are accessing it throug a
proxy and some proxy settings were changed, so the webserver is running
slower? (of course this wouldn't excplain the fact, the the code ran
slower on other machines too).

David

attached mail follows:


On Wed, 20 Oct 2004 14:59:01 +0200, Janke Dávid <djyangcefreemail.hu> wrote:
> HEEEEEEEEEEEEEEEEEEEEEEEELP!

In my experience the most common network slowdown issues involve
overloaded isp DNS servers. I'd do a few nslookups and see how
responsive their nameservers are. You can easily add 4-5 seconds to a
php script's execution time with a bad nameserver. Then you add a
proxy server in there as you described and things will only get worse.

You might want to see if there's any packet loss with a ping test too.

--
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

attached mail follows:


Hi,

I am trying to use the strtotime function to get dates for the first and
last days of a given week:

<?php
 echo date("Y-m-d", strtotime("last monday",
strtotime("2004-10-18"))).'<br>';
 echo date("Y-m-d", strtotime("sunday", strtotime("2004-10-18")));
?>

Using the code above works fine until the date input is a Monday then it
outputs the date of the previous Monday. Does anyone know of another way?

Thanks for your help

attached mail follows:


To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

> -----Original Message-----
> From: Shaun [mailto:shaunthornburghhotmail.com]
> Sent: 20 October 2004 11:35
>
> I am trying to use the strtotime function to get dates for
> the first and
> last days of a given week:
>
> <?php
> echo date("Y-m-d", strtotime("last monday",
> strtotime("2004-10-18"))).'<br>';
> echo date("Y-m-d", strtotime("sunday", strtotime("2004-10-18"))); ?>
>
> Using the code above works fine until the date input is a
> Monday then it
> outputs the date of the previous Monday. Does anyone know of
> another way?

I believe my solution to this went something along the lines of

    strtotime("-6 days monday", ....);

It's quite a while since I last used this, so I might not have it quite
right, but this should set you on the road.

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services, JG125, James
Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS,
LS6 3QS, United Kingdom
Email: m.fordleedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

attached mail follows:


Great!

Really, if your purpose was to be helpful, you failed miserably.
The helpful part would have been that you would've actually hinted as
into _how_ it was possible.

I'm not looking for ready solutions or ready scripts, but with messages
like these you really only waste other peoples' time.

M. Sokolewicz wrote:

>> Would it be possible to create a member variable to a class on the
>> fly, without specifically creating it when you write the class?
>> Something like this:
>
> possible.
>
>>
>> Or could it even be possible to do this outside of a class? So that I
>
> yes, that is possible.
>

--
developer & programmer
me tomi kaistila
home http://www.datamike.org
gnupg 0xFA63E4C7

attached mail follows:


On Wed, 20 Oct 2004 13:41:16 +0300, Tomi Kaistila
<tomi.kaistiladatamike.org> wrote:
> Really, if your purpose was to be helpful, you failed miserably.
> The helpful part would have been that you would've actually hinted as
> into _how_ it was possible.
>
> I'm not looking for ready solutions or ready scripts, but with messages
> like these you really only waste other peoples' time.

Did you search the mailing list archives already?

http://marc.theaimsgroup.com/?l=php-general&m=109509393613288&w=2

--
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

attached mail follows:


Hi Tomy,

I did the same thing!

I´ve used a class called framework to encapsulate everything... here is
what looks like:

framework.inc.php
<?php
/**
* Project: BBBM Framework
* File: framework.inc.php
*
* desc Main Framework Include
* link http://www.bbbm.com.br/
* copyright 2004 Bruno B B Magalhaes
* author Bruno B B Magalhaes <brunomagalhaesbbbm.com.br>
* package BBBM Framework
* version 0.5-dev
*/
session_start();

/**
* Include Core Classes
*/
require_once(FRAMEWORK_DIR.'core/framework.class.php');
require_once(FRAMEWORK_DIR.'core/preferences.class.php');
require_once(FRAMEWORK_DIR.'core/languages.class.php');
require_once(FRAMEWORK_DIR.'core/database.class.php');
require_once(FRAMEWORK_DIR.'core/authentication.class.php');
require_once(FRAMEWORK_DIR.'core/input.class.php');
require_once(FRAMEWORK_DIR.'smarty/smarty.class.php');
require_once(FRAMEWORK_DIR.'core/output.class.php');
require_once(FRAMEWORK_DIR.'core/modules.class.php');
require_once(FRAMEWORK_DIR.'core/validation.class.php');
require_once(FRAMEWORK_DIR.'core/filters.class.php');

/**
* Include Shared Classes
*/
include_once(FRAMEWORK_DIR.'shared/categories.class.php');

?>

framework.class.php
<?php
/**
* Project: BBBM Framework
* File: framework.class.php
*
* desc Main Framework Class
* link http://www.bbbm.com.br/
* copyright 2004 Bruno B B Magalhaes
* author Bruno B B Magalhaes <brunomagalhaesbbbm.com.br>
* package BBBM Framework
* version 0.5-dev
*/
class framework
{
        var $preferences;
        var $database;
        var $authentication;
        var $input;
        var $output;
        var $modules;
        var $validation;
        var $filters;
        var $languages;
        
        var $controller;
        
        /**
        * PHP 4 Constructor
        */
        function framework()
        {
                $this->preferences = new preferences(); // Preferences Layer
                $this->languages = new languages(); // Language Layer
                $this->database = new database($this->preferences); // Database Layer
                $this->input = new input(); // Input Layer
                $this->modules = new modules($this->database); // Modules Layer
                $this->authentication = new authentication($this->database); //
Authentication Layer
                $this->output = new output($this->preferences,$this->languages); //
Ouput Layer
                $this->validation = new validation(); // Validation functions
                $this->filters = new filters(); // Filters Functions
        }
        
        function is_valid_controller($contoller='')
        {
                if($contoller != '')
                {
                        $contoller = addslashes(strip_tags($contoller));
                        $this->database->build_table(array('controllers'));
                        
                        $query = 'SELECT
                                        controllerStatus
                                    FROM
                                        '.$this->database->table['controllers'].'
                                    WHERE
                                        controllerPath=\''.$contoller.'\'
                                    ';
                        
                        $this->database->query($query);
                        
                        if($this->database->num_rows() > 0)
                        {
                                $this->database->fetch_array();
                                
                                if($this->database->row['controllerStatus'] > 0)
                                {
                                        $this->controller = $contoller;
                                        return true;
                                }
                                else
                                {
                                        $this->controller = false;
                                        return false;
                                }
                        }
                        else
                        {
                                $this->controller = false;
                                return false;
                        }
                }
                else
                {
                        return false;
                }
        }
}
?>

Regards,
Bruno B B Magalhães

attached mail follows:


Hi Tomy,

I did the same thing!

I´ve used a class called framework to encapsulate everything... here is
what looks like:

framework.inc.php
<?php
/**
* Project: BBBM Framework
* File: framework.inc.php
*
* desc Main Framework Include
* link http://www.bbbm.com.br/
* copyright 2004 Bruno B B Magalhaes
* author Bruno B B Magalhaes <brunomagalhaesbbbm.com.br>
* package BBBM Framework
* version 0.5-dev
*/
session_start();

/**
* Include Core Classes
*/
require_once(FRAMEWORK_DIR.'core/framework.class.php');
require_once(FRAMEWORK_DIR.'core/preferences.class.php');
require_once(FRAMEWORK_DIR.'core/languages.class.php');
require_once(FRAMEWORK_DIR.'core/database.class.php');
require_once(FRAMEWORK_DIR.'core/authentication.class.php');
require_once(FRAMEWORK_DIR.'core/input.class.php');
require_once(FRAMEWORK_DIR.'smarty/smarty.class.php');
require_once(FRAMEWORK_DIR.'core/output.class.php');
require_once(FRAMEWORK_DIR.'core/modules.class.php');
require_once(FRAMEWORK_DIR.'core/validation.class.php');
require_once(FRAMEWORK_DIR.'core/filters.class.php');

/**
* Include Shared Classes
*/
include_once(FRAMEWORK_DIR.'shared/categories.class.php');

?>

framework.class.php
<?php
/**
* Project: BBBM Framework
* File: framework.class.php
*
* desc Main Framework Class
* link http://www.bbbm.com.br/
* copyright 2004 Bruno B B Magalhaes
* author Bruno B B Magalhaes <brunomagalhaesbbbm.com.br>
* package BBBM Framework
* version 0.5-dev
*/
class framework
{
        var $preferences;
        var $database;
        var $authentication;
        var $input;
        var $output;
        var $modules;
        var $validation;
        var $filters;
        var $languages;
        
        var $controller;
        
        /**
        * PHP 4 Constructor
        */
        function framework()
        {
                $this->preferences = new preferences(); // Preferences Layer
                $this->languages = new languages(); // Language Layer
                $this->database = new database($this->preferences); // Database Layer
                $this->input = new input(); // Input Layer
                $this->modules = new modules($this->database); // Modules Layer
                $this->authentication = new authentication($this->database); //
Authentication Layer
                $this->output = new output($this->preferences,$this->languages); //
Ouput Layer
                $this->validation = new validation(); // Validation functions
                $this->filters = new filters(); // Filters Functions
        }
        
        function is_valid_controller($contoller='')
        {
                if($contoller != '')
                {
                        $contoller = addslashes(strip_tags($contoller));
                        $this->database->build_table(array('controllers'));
                        
                        $query = 'SELECT
                                        controllerStatus
                                    FROM
                                        '.$this->database->table['controllers'].'
                                    WHERE
                                        controllerPath=\''.$contoller.'\'
                                    ';
                        
                        $this->database->query($query);
                        
                        if($this->database->num_rows() > 0)
                        {
                                $this->database->fetch_array();
                                
                                if($this->database->row['controllerStatus'] > 0)
                                {
                                        $this->controller = $contoller;
                                        return true;
                                }
                                else
                                {
                                        $this->controller = false;
                                        return false;
                                }
                        }
                        else
                        {
                                $this->controller = false;
                                return false;
                        }
                }
                else
                {
                        return false;
                }
        }
}
?>

Regards,
Bruno B B Magalhães

attached mail follows:


Hi all!

I finally got what I was after, after numerous tips and suggestion.
Thank you for your patience. Special thanks to Bruno Magalhães, Thomas
Goyne, and Davy Obdam.

Thanks again :-)

--
developer & programmer
me tomi kaistila
home http://www.datamike.org
gnupg 0xFA63E4C7

attached mail follows:


Hi
I have a serious problem:
The client want's to emigrate the webhosting from a unix server to a windows
server. Now my biggest problem are the path's.
Is there a way to fast convert all the /root-style directories into the
windows standard \ ??
Thanks for your consideration, I have the strong feeling that this is much
work coming.

--
Patrick Fehr
Swiss Federal Institute Of Technology

attached mail follows:


On Wed, 2004-10-20 at 07:17, Patrick Fehr wrote:
> Hi
> I have a serious problem:
> The client want's to emigrate the webhosting from a unix server to a windows
> server. Now my biggest problem are the path's.
> Is there a way to fast convert all the /root-style directories into the
> windows standard \ ??
> Thanks for your consideration, I have the strong feeling that this is much
> work coming.

Conversion of / to \ is done for you by PHP. The only thing you might
need to consider is the drive on which PHP is installed.

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

attached mail follows:


On Wed, 20 Oct 2004 13:17:08 +0200, Patrick Fehr <fehrpee.ethz.ch> wrote:
> I have a serious problem:
> The client want's to emigrate the webhosting from a unix server to a windows
> server. Now my biggest problem are the path's.
> Is there a way to fast convert all the /root-style directories into the
> windows standard \ ??
> Thanks for your consideration, I have the strong feeling that this is much
> work coming.

A small sed script would easily handle this conversion. I doubt you
have any of those on windows so I'd do the conversion before moving.

for file in *.php; do
cp $file $file.tmp
sed -e "s/\//\\\\/g" $file.tmp >$file
rm $file.tmp
done

Remember on windows you will be dealing with backslashes instead of
forward slashes, and you have to escape the backslashes with
backslashes.

$path = '/usr/local/blah';

will be something like:

$path = 'c:\\inetpub\\www';

--
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

attached mail follows:


Just a point: this will be a problem if they have some forward slashes
that are not specifying file paths, i.e. URLs in the code like
http://www.whereveryouwant.com/ will be substituted by
http:\\www.whereveryouwant.com\

Greg Donald wrote:

>On Wed, 20 Oct 2004 13:17:08 +0200, Patrick Fehr <fehrpee.ethz.ch> wrote:
>
>
>>I have a serious problem:
>>The client want's to emigrate the webhosting from a unix server to a windows
>>server. Now my biggest problem are the path's.
>>Is there a way to fast convert all the /root-style directories into the
>>windows standard \ ??
>>Thanks for your consideration, I have the strong feeling that this is much
>>work coming.
>>
>>
>
>A small sed script would easily handle this conversion. I doubt you
>have any of those on windows so I'd do the conversion before moving.
>
>for file in *.php; do
>cp $file $file.tmp
>sed -e "s/\//\\\\/g" $file.tmp >$file
>rm $file.tmp
>done
>
>Remember on windows you will be dealing with backslashes instead of
>forward slashes, and you have to escape the backslashes with
>backslashes.
>
>$path = '/usr/local/blah';
>
>will be something like:
>
>$path = 'c:\\inetpub\\www';
>
>
>
>

attached mail follows:


After some back and forth posts here I had finally
thought my array issue was over, but!

To review I have 30 form elements on a page
10 are skill[]
10 are sky[]
10 are slu[]

I pass them as session variables

$_SESSION['skills'] = $_POST['skill'];
$_SESSION['skys'] = $_POST['sky'];
$_SESSION['slus'] = $_POST['slu'];

Then when everyting is passed into a database
transaction:

$skills = $_SESSION['skills'];
$skys = $_SESSION['skys'];
$slus = $_SESSION['slus'];

foreach($_SESSION['skills'] as $key => $skill)
{
$query = "INSERT INTO Profiles_skills (ProfileID,
SkilCerts, NumYear, Lused)
VALUES ($LID, '$skill',
{$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]})";
//$result = mysql_query($query);

Here is the problem:

Using
(((isset($_POST["skill[]"]))?$_POST["skill[]"]:"") .
"",true,true,true,true,"",false,1);

I can't seem to differentiate between the the elements
because they are all labeled skill[]
So basically validation isn't doing anything .

I'm thinking of finding a better way to validate , or
if i change the elements to skill[1], skill[2] , what
would that do to my iteration loop ?

Thank you,
Stuart

attached mail follows:


Not sure I really know where you have the problem, but I am assuming you are
trying to construct the INSERT statement within your foreach loop.

If so, why use $_POST["skill[]"] when you have $skill which is that current
element being iterated?
Did you read the foreach doc?
http://uk2.php.net/manual/en/control-structures.foreach.php

HTH
Graham

> -----Original Message-----
> From: Stuart Felenstein [mailto:stuart4myahoo.com]
> Sent: 20 October 2004 13:35
> To: php-generallists.php.net
> Subject: [PHP] Validation problem with array.
>
>
> After some back and forth posts here I had finally
> thought my array issue was over, but!
>
> To review I have 30 form elements on a page
> 10 are skill[]
> 10 are sky[]
> 10 are slu[]
>
> I pass them as session variables
>
> $_SESSION['skills'] = $_POST['skill'];
> $_SESSION['skys'] = $_POST['sky'];
> $_SESSION['slus'] = $_POST['slu'];
>
> Then when everyting is passed into a database
> transaction:
>
> $skills = $_SESSION['skills'];
> $skys = $_SESSION['skys'];
> $slus = $_SESSION['slus'];
>
> foreach($_SESSION['skills'] as $key => $skill)
> {
> $query = "INSERT INTO Profiles_skills (ProfileID,
> SkilCerts, NumYear, Lused)
> VALUES ($LID, '$skill',
> {$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]})";
> //$result = mysql_query($query);
>
> Here is the problem:
>
> Using
> (((isset($_POST["skill[]"]))?$_POST["skill[]"]:"") .
> "",true,true,true,true,"",false,1);
>
> I can't seem to differentiate between the the elements
> because they are all labeled skill[]
> So basically validation isn't doing anything .
>
> I'm thinking of finding a better way to validate , or
> if i change the elements to skill[1], skill[2] , what
> would that do to my iteration loop ?
>
> Thank you,
> Stuart
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


My problem is not related to the insert or iteration.
It's related to the validaton of those elements:
skill[]
skill[]
etc.

Clearer ?

Stuart
--- Graham Cossey <grahamcossey.plus.com> wrote:

> Not sure I really know where you have the problem,
> but I am assuming you are
> trying to construct the INSERT statement within your
> foreach loop.
>
> If so, why use $_POST["skill[]"] when you have
> $skill which is that current
> element being iterated?
> Did you read the foreach doc?
>
http://uk2.php.net/manual/en/control-structures.foreach.php
>
> HTH
> Graham
>
>
> > -----Original Message-----
> > From: Stuart Felenstein
> [mailto:stuart4myahoo.com]
> > Sent: 20 October 2004 13:35
> > To: php-generallists.php.net
> > Subject: [PHP] Validation problem with array.
> >
> >
> > After some back and forth posts here I had finally
> > thought my array issue was over, but!
> >
> > To review I have 30 form elements on a page
> > 10 are skill[]
> > 10 are sky[]
> > 10 are slu[]
> >
> > I pass them as session variables
> >
> > $_SESSION['skills'] = $_POST['skill'];
> > $_SESSION['skys'] = $_POST['sky'];
> > $_SESSION['slus'] = $_POST['slu'];
> >
> > Then when everyting is passed into a database
> > transaction:
> >
> > $skills = $_SESSION['skills'];
> > $skys = $_SESSION['skys'];
> > $slus = $_SESSION['slus'];
> >
> > foreach($_SESSION['skills'] as $key => $skill)
> > {
> > $query = "INSERT INTO Profiles_skills (ProfileID,
> > SkilCerts, NumYear, Lused)
> > VALUES ($LID, '$skill',
> >
>
{$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]})";
> > //$result = mysql_query($query);
> >
> > Here is the problem:
> >
> > Using
> > (((isset($_POST["skill[]"]))?$_POST["skill[]"]:"")
> .
> > "",true,true,true,true,"",false,1);
> >
> > I can't seem to differentiate between the the
> elements
> > because they are all labeled skill[]
> > So basically validation isn't doing anything .
> >
> > I'm thinking of finding a better way to validate ,
> or
> > if i change the elements to skill[1], skill[2] ,
> what
> > would that do to my iteration loop ?
> >
> > Thank you,
> > Stuart
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit:
> http://www.php.net/unsub.php
> >
> >
>
>
>

attached mail follows:


Maybe you would like to post your validation code then.

I (we) do not know where the line:

(((isset($_POST["skill[]"]))?$_POST["skill[]"]:"")."",true,true,true,true,""
,false,1);

is being called.

Have you thought about using an iteration as you have when constructing the
INSERT statement?
Have you considered placing validation within the iteration you have when
constructing the INSERT statement?

If you do a print_r($skills) you will see that although in the form they are
named skill[] when passed to your script they will be skill[0], skill[1],
skill[2]...

Also, this line :

foreach($_SESSION['skills'] as $key => $skill)

could read

foreach($skills as $key => $skill)

as you have the line:

$skills = $_SESSION['skills'];

Same for skys and slus.

Graham

> -----Original Message-----
> From: Stuart Felenstein [mailto:stuart4myahoo.com]
> Sent: 20 October 2004 14:06
> To: Graham Cossey; php-generallists.php.net
> Subject: RE: [PHP] Validation problem with array.
>
>
> My problem is not related to the insert or iteration.
> It's related to the validaton of those elements:
> skill[]
> skill[]
> etc.
>
> Clearer ?
>
> Stuart
> --- Graham Cossey <grahamcossey.plus.com> wrote:
>
> > Not sure I really know where you have the problem,
> > but I am assuming you are
> > trying to construct the INSERT statement within your
> > foreach loop.
> >
> > If so, why use $_POST["skill[]"] when you have
> > $skill which is that current
> > element being iterated?
> > Did you read the foreach doc?
> >
> http://uk2.php.net/manual/en/control-structures.foreach.php
> >
> > HTH
> > Graham
> >
> >
> > > -----Original Message-----
> > > From: Stuart Felenstein
> > [mailto:stuart4myahoo.com]
> > > Sent: 20 October 2004 13:35
> > > To: php-generallists.php.net
> > > Subject: [PHP] Validation problem with array.
> > >
> > >
> > > After some back and forth posts here I had finally
> > > thought my array issue was over, but!
> > >
> > > To review I have 30 form elements on a page
> > > 10 are skill[]
> > > 10 are sky[]
> > > 10 are slu[]
> > >
> > > I pass them as session variables
> > >
> > > $_SESSION['skills'] = $_POST['skill'];
> > > $_SESSION['skys'] = $_POST['sky'];
> > > $_SESSION['slus'] = $_POST['slu'];
> > >
> > > Then when everyting is passed into a database
> > > transaction:
> > >
> > > $skills = $_SESSION['skills'];
> > > $skys = $_SESSION['skys'];
> > > $slus = $_SESSION['slus'];
> > >
> > > foreach($_SESSION['skills'] as $key => $skill)
> > > {
> > > $query = "INSERT INTO Profiles_skills (ProfileID,
> > > SkilCerts, NumYear, Lused)
> > > VALUES ($LID, '$skill',
> > >
> >
> {$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]})";
> > > //$result = mysql_query($query);
> > >
> > > Here is the problem:
> > >
> > > Using
> > > (((isset($_POST["skill[]"]))?$_POST["skill[]"]:"")
> > .
> > > "",true,true,true,true,"",false,1);
> > >
> > > I can't seem to differentiate between the the
> > elements
> > > because they are all labeled skill[]
> > > So basically validation isn't doing anything .
> > >
> > > I'm thinking of finding a better way to validate ,
> > or
> > > if i change the elements to skill[1], skill[2] ,
> > what
> > > would that do to my iteration loop ?
> > >
> > > Thank you,
> > > Stuart
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit:
> > http://www.php.net/unsub.php
> > >
> > >
> >
> >
> >
>
>

attached mail follows:


Believe it or not I had just thought of doing a
foreach with the validation.

I'll see how it goes.

Stuart
--- Graham Cossey <grahamcossey.plus.com> wrote:

> Maybe you would like to post your validation code
> then.
>
> I (we) do not know where the line:
>
>
(((isset($_POST["skill[]"]))?$_POST["skill[]"]:"")."",true,true,true,true,""
> ,false,1);
>
> is being called.
>
> Have you thought about using an iteration as you
> have when constructing the
> INSERT statement?
> Have you considered placing validation within the
> iteration you have when
> constructing the INSERT statement?
>
> If you do a print_r($skills) you will see that
> although in the form they are
> named skill[] when passed to your script they will
> be skill[0], skill[1],
> skill[2]...
>
> Also, this line :
>
> foreach($_SESSION['skills'] as $key => $skill)
>
> could read
>
> foreach($skills as $key => $skill)
>
> as you have the line:
>
> $skills = $_SESSION['skills'];
>
> Same for skys and slus.
>
> Graham
>
> > -----Original Message-----
> > From: Stuart Felenstein
> [mailto:stuart4myahoo.com]
> > Sent: 20 October 2004 14:06
> > To: Graham Cossey; php-generallists.php.net
> > Subject: RE: [PHP] Validation problem with array.
> >
> >
> > My problem is not related to the insert or
> iteration.
> > It's related to the validaton of those elements:
> > skill[]
> > skill[]
> > etc.
> >
> > Clearer ?
> >
> > Stuart
> > --- Graham Cossey <grahamcossey.plus.com> wrote:
> >
> > > Not sure I really know where you have the
> problem,
> > > but I am assuming you are
> > > trying to construct the INSERT statement within
> your
> > > foreach loop.
> > >
> > > If so, why use $_POST["skill[]"] when you have
> > > $skill which is that current
> > > element being iterated?
> > > Did you read the foreach doc?
> > >
> >
>
http://uk2.php.net/manual/en/control-structures.foreach.php
> > >
> > > HTH
> > > Graham
> > >
> > >
> > > > -----Original Message-----
> > > > From: Stuart Felenstein
> > > [mailto:stuart4myahoo.com]
> > > > Sent: 20 October 2004 13:35
> > > > To: php-generallists.php.net
> > > > Subject: [PHP] Validation problem with array.
> > > >
> > > >
> > > > After some back and forth posts here I had
> finally
> > > > thought my array issue was over, but!
> > > >
> > > > To review I have 30 form elements on a page
> > > > 10 are skill[]
> > > > 10 are sky[]
> > > > 10 are slu[]
> > > >
> > > > I pass them as session variables
> > > >
> > > > $_SESSION['skills'] = $_POST['skill'];
> > > > $_SESSION['skys'] = $_POST['sky'];
> > > > $_SESSION['slus'] = $_POST['slu'];
> > > >
> > > > Then when everyting is passed into a database
> > > > transaction:
> > > >
> > > > $skills = $_SESSION['skills'];
> > > > $skys = $_SESSION['skys'];
> > > > $slus = $_SESSION['slus'];
> > > >
> > > > foreach($_SESSION['skills'] as $key => $skill)
> > > > {
> > > > $query = "INSERT INTO Profiles_skills
> (ProfileID,
> > > > SkilCerts, NumYear, Lused)
> > > > VALUES ($LID, '$skill',
> > > >
> > >
> >
>
{$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]})";
> > > > //$result = mysql_query($query);
> > > >
> > > > Here is the problem:
> > > >
> > > > Using
> > > >
> (((isset($_POST["skill[]"]))?$_POST["skill[]"]:"")
> > > .
> > > > "",true,true,true,true,"",false,1);
> > > >
> > > > I can't seem to differentiate between the the
> > > elements
> > > > because they are all labeled skill[]
> > > > So basically validation isn't doing anything .
> > > >
> > > > I'm thinking of finding a better way to
> validate ,
> > > or
> > > > if i change the elements to skill[1], skill[2]
> ,
> > > what
> > > > would that do to my iteration loop ?
> > > >
> > > > Thank you,
> > > > Stuart
> > > >
> > > > --
> > > > PHP General Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit:
> > > http://www.php.net/unsub.php
> > > >
> > > >
> > >
> > >
> > >
> >
> >
>
>
>

attached mail follows:


I think I might know what you are trying to do. You want to have a
"name" associated with the skill (or skys or slus). You can use an
associative array to "name" your array elements. In your form, you can
change the array to be something like this:
skills[cooking]
skills[flying]
skills[walking]
...

Notice there are no quotes around the skill names. Now each array
element has an array key that is a name. The computer doesn't really
care, but it makes it easier for you to read your code. And you now
have name/value pairs. You can process the array like this:

$skillNames = array_keys($skills);
foreach($skillNames as $skill) {
        echo 'Skill: '.$skill.' Value: '.$skills[$skill].' <br />';
}

Of course, instead of echoing you would do your validation or
substitution.

On Oct 20, 2004, at 8:35 AM, Stuart Felenstein wrote:

> After some back and forth posts here I had finally
> thought my array issue was over, but!
>
> To review I have 30 form elements on a page
> 10 are skill[]
> 10 are sky[]
> 10 are slu[]
>
> I pass them as session variables
>
> $_SESSION['skills'] = $_POST['skill'];
> $_SESSION['skys'] = $_POST['sky'];
> $_SESSION['slus'] = $_POST['slu'];
>
> Then when everyting is passed into a database
> transaction:
>
> $skills = $_SESSION['skills'];
> $skys = $_SESSION['skys'];
> $slus = $_SESSION['slus'];
>
> foreach($_SESSION['skills'] as $key => $skill)
> {
> $query = "INSERT INTO Profiles_skills (ProfileID,
> SkilCerts, NumYear, Lused)
> VALUES ($LID, '$skill',
> {$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]})";
> //$result = mysql_query($query);
>
> Here is the problem:
>
> Using
> (((isset($_POST["skill[]"]))?$_POST["skill[]"]:"") .
> "",true,true,true,true,"",false,1);
>
> I can't seem to differentiate between the the elements
> because they are all labeled skill[]
> So basically validation isn't doing anything .
>
> I'm thinking of finding a better way to validate , or
> if i change the elements to skill[1], skill[2] , what
> would that do to my iteration loop ?
>
> Thank you,
> Stuart
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577

attached mail follows:


Brent,
Thank you , I can't do an associative because it part
of a user input form. The values will be dependent on
the users. I'm going to try and give each form
element a index number skill[0], skill[1] since the
foreach loop is doing that anyway.

The reason I haven't posted the validation is because
it's part of a class, so what exists in the page is
only part of the code.

Stuart

--- Brent Baisley <brentlandover.com> wrote:

> I think I might know what you are trying to do. You
> want to have a
> "name" associated with the skill (or skys or slus).
> You can use an
> associative array to "name" your array elements. In
> your form, you can
> change the array to be something like this:
> skills[cooking]
> skills[flying]
> skills[walking]
> ...
>
> Notice there are no quotes around the skill names.
> Now each array
> element has an array key that is a name. The
> computer doesn't really
> care, but it makes it easier for you to read your
> code. And you now
> have name/value pairs. You can process the array
> like this:
>
> $skillNames = array_keys($skills);
> foreach($skillNames as $skill) {
> echo 'Skill: '.$skill.' Value: '.$skills[$skill].'
> <br />';
> }
>
> Of course, instead of echoing you would do your
> validation or
> substitution.
>
> On Oct 20, 2004, at 8:35 AM, Stuart Felenstein
> wrote:
>
> > After some back and forth posts here I had finally
> > thought my array issue was over, but!
> >
> > To review I have 30 form elements on a page
> > 10 are skill[]
> > 10 are sky[]
> > 10 are slu[]
> >
> > I pass them as session variables
> >
> > $_SESSION['skills'] = $_POST['skill'];
> > $_SESSION['skys'] = $_POST['sky'];
> > $_SESSION['slus'] = $_POST['slu'];
> >
> > Then when everyting is passed into a database
> > transaction:
> >
> > $skills = $_SESSION['skills'];
> > $skys = $_SESSION['skys'];
> > $slus = $_SESSION['slus'];
> >
> > foreach($_SESSION['skills'] as $key => $skill)
> > {
> > $query = "INSERT INTO Profiles_skills (ProfileID,
> > SkilCerts, NumYear, Lused)
> > VALUES ($LID, '$skill',
> >
>
{$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]})";
> > //$result = mysql_query($query);
> >
> > Here is the problem:
> >
> > Using
> > (((isset($_POST["skill[]"]))?$_POST["skill[]"]:"")
> .
> > "",true,true,true,true,"",false,1);
> >
> > I can't seem to differentiate between the the
> elements
> > because they are all labeled skill[]
> > So basically validation isn't doing anything .
> >
> > I'm thinking of finding a better way to validate ,
> or
> > if i change the elements to skill[1], skill[2] ,
> what
> > would that do to my iteration loop ?
> >
> > Thank you,
> > Stuart
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit:
> http://www.php.net/unsub.php
> >
> >
> --
> Brent Baisley
> Systems Architect
> Landover Associates, Inc.
> Search & Advisory Services for Advanced Technology
> Environments
> p: 212.759.6400/800.759.0577
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


I thought you were using checkboxes based on your true/false. So the
user is actually typing in skills?

Not sure where you are going with skill[0], skill[1]. You are creating
an associative array when you do that. In and input form, skill[0] and
skill[a] are actually no different, aside from the name you are using
for that element.

On Oct 20, 2004, at 9:41 AM, Stuart Felenstein wrote:

> Brent,
> Thank you , I can't do an associative because it part
> of a user input form. The values will be dependent on
> the users. I'm going to try and give each form
> element a index number skill[0], skill[1] since the
> foreach loop is doing that anyway.
>
> The reason I haven't posted the validation is because
> it's part of a class, so what exists in the page is
> only part of the code.
>
> Stuart
>
>
> --- Brent Baisley <brentlandover.com> wrote:
>
>> I think I might know what you are trying to do. You
>> want to have a
>> "name" associated with the skill (or skys or slus).
>> You can use an
>> associative array to "name" your array elements. In
>> your form, you can