php-general Digest 18 Sep 2002 10:16:23 -0000 Issue 1592

Topics (messages 116666 through 116709):

Re: strange bug(?) when opening lots of files
        116666 by: Tyler Longren
        116668 by: Shane Wright
        116669 by: nicos.php.net
        116670 by: Shane Wright
        116671 by: nicos.php.net

Please, Help dynamicaly creating an Array
        116667 by: Max Sullivan
        116691 by: Marek Kilimajer

adding unix account via system command
        116672 by: tim tom
        116676 by: Peter Houchin
        116677 by: tim tom
        116678 by: Peter Houchin
        116693 by: Marek Kilimajer

Conditionally include file based on document location
        116673 by: Eric C. Pollitt
        116694 by: Marek Kilimajer

Help.....still stuck after 3 days :/
        116674 by: Chad Winger
        116705 by: Marek Kilimajer
        116709 by: Ford, Mike               [LSS]

PHP and Microsoft Office
        116675 by: Matthew Tapia
        116706 by: Marek Kilimajer

Re: Regex for split() to split by , which is not in ()s?
        116679 by: David Robley

hidden PATH_INFO
        116680 by: perlguy9

Re: [PHP-GTK] problems with socket
        116681 by: Steph

PHP and Flash
        116682 by: icaam.icaam.com.ar
        116683 by: Rasmus Lerdorf

Re: callbacks to methods inside a class/object
        116684 by: Tom Rogers

Re: can you get the name of an object from within it's own class?
        116685 by: Simon McKenna

Re: any new form builders
        116686 by: Justin French

Messaging Solution
        116687 by: karthikeyan
        116698 by: Marek Kilimajer

mid-level PHP/MySQL people in Los Angeles?
        116688 by: PHP freak

replacing mail()
        116689 by: Liam
        116696 by: Marek Kilimajer

Re: Redirecting - header location - sometimes not work
        116690 by: Marek Kilimajer

time to seconds
        116692 by: adi
        116695 by: Denis Basta
        116697 by: Marek Kilimajer
        116700 by: Warren Daly

Auto-increment value
        116699 by: Faisal Abdullah
        116701 by: Scott Houseman
        116702 by: Erwin
        116703 by: Marek Kilimajer
        116707 by: Justin French
        116708 by: Faisal Abdullah

Re: note 25286 added to function.mb-strcut
        116704 by: nicos.php.net

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
How long does the script tend to run before it just "quits"?  Perhaps
a timeout is set too low in php.ini.

Take a look at max_execution_time in php.ini

tyler

On Tue, 17 Sep 2002 23:14:46 +0100
Shane Wright <[EMAIL PROTECTED]> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi
> 
> One of my pages opens ~100 files, reads from them, and closes them,
> (only one file open at a time).
> 
> The problem is that the page just dies mid-way through execution - no
> errors, no segfault, it just dies and returns a blank page to the
> user.  the problem goes away if I reduce the number of files accessed.
> 
> its a build of PHP 4.1.2 on Linux running as an Apache module,  (if it
> makes any odds, the configure line is below).
> 
> I can't see anything on bugs.php.net about this - has anyone seen this
> before (and, of course, the crucial question; what can I do to fix
> it?)
> 
> Any help appreciated,
> 
> Thanks
> 
> - -- 
> Shane
> http://www.shanewright.co.uk/
> Public key: http://www.shanewright.co.uk/files/public_key.asc
> 
> 
>  './configure' '--with-gd' '--enable-gd-native-ttf'
>  '--enable-track-vars' 
> '--enable-sysvsem' '--enable-sysvshm' '--enable-calendar'
> '--with-zlib' '--prefix=/opt/php-4.1'
> '--with-config-file-path=/usr/local/etc/httpd/conf'
> '--enable-memory-limit' '--with-db2=/usr' '--with-db3=/usr'
> '--with-gdbm=/usr' '--with-ndbm=/usr' '--with-dbase' '--with-xml'
> '--with-expat-dir=/usr' '--enable-debugger' '--enable-ftp'
> '--with-ttf' '--with-jpeg-dir=/usr' '--enable-bcmath' '--with-openssl'
> 
> '--enable-trans-sid' '--with-mysql=/usr' '--with-xpm-dir=/usr/X11R6' 
> '--with-png' '--with-png-dir=/usr' '--with-imap' '--with-dom=/usr' 
> '--with-bz2' '--with-curl' '--with-mhash=/usr' '--with-mcrypt=/usr' 
> '--with-pgsql' '--with-gmp' '--with-gettext' '--with-iconv'
> '--with-kerberos' '--enable-xslt' '--with-xslt-sablot'
> '--with-freetype-dir=/usr' '--with-apxs=/usr/sbin/apxs'
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.7 (GNU/Linux)
> 
> iD8DBQE9h6lW5DXg6dCMBrQRAhhiAKCIo1xdyyDtx7fT8SO8Xz4bfWOg7QCfdjE3
> STUVeNEID6bzu4+hq+PqCI4=
> =zZqL
> -----END PGP SIGNATURE-----
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Thanks for the input - but its definately not that; time limit is set to 600 
seconds and it dies inside 1 second :(

(i should have added this to the original mail, but it seems to supply the 
page but keep the connection open, strange...)

S

On Wednesday 18 September 2002 12:01 am, Tyler Longren wrote:
> How long does the script tend to run before it just "quits"?  Perhaps
> a timeout is set too low in php.ini.
>
> Take a look at max_execution_time in php.ini
>
> tyler
>
> On Tue, 17 Sep 2002 23:14:46 +0100
>
> Shane Wright <[EMAIL PROTECTED]> wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Hi
> >
> > One of my pages opens ~100 files, reads from them, and closes them,
> > (only one file open at a time).
> >
> > The problem is that the page just dies mid-way through execution - no
> > errors, no segfault, it just dies and returns a blank page to the
> > user.  the problem goes away if I reduce the number of files accessed.
> >
> > its a build of PHP 4.1.2 on Linux running as an Apache module,  (if it
> > makes any odds, the configure line is below).
> >
> > I can't see anything on bugs.php.net about this - has anyone seen this
> > before (and, of course, the crucial question; what can I do to fix
> > it?)
> >
> > Any help appreciated,
> >
> > Thanks
> >
> > - --
> > Shane
> > http://www.shanewright.co.uk/
> > Public key: http://www.shanewright.co.uk/files/public_key.asc
> >
> >
> >  './configure' '--with-gd' '--enable-gd-native-ttf'
> >  '--enable-track-vars'
> > '--enable-sysvsem' '--enable-sysvshm' '--enable-calendar'
> > '--with-zlib' '--prefix=/opt/php-4.1'
> > '--with-config-file-path=/usr/local/etc/httpd/conf'
> > '--enable-memory-limit' '--with-db2=/usr' '--with-db3=/usr'
> > '--with-gdbm=/usr' '--with-ndbm=/usr' '--with-dbase' '--with-xml'
> > '--with-expat-dir=/usr' '--enable-debugger' '--enable-ftp'
> > '--with-ttf' '--with-jpeg-dir=/usr' '--enable-bcmath' '--with-openssl'
> >
> > '--enable-trans-sid' '--with-mysql=/usr' '--with-xpm-dir=/usr/X11R6'
> > '--with-png' '--with-png-dir=/usr' '--with-imap' '--with-dom=/usr'
> > '--with-bz2' '--with-curl' '--with-mhash=/usr' '--with-mcrypt=/usr'
> > '--with-pgsql' '--with-gmp' '--with-gettext' '--with-iconv'
> > '--with-kerberos' '--enable-xslt' '--with-xslt-sablot'
> > '--with-freetype-dir=/usr' '--with-apxs=/usr/sbin/apxs'
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.0.7 (GNU/Linux)
> >
> > iD8DBQE9h6lW5DXg6dCMBrQRAhhiAKCIo1xdyyDtx7fT8SO8Xz4bfWOg7QCfdjE3
> > STUVeNEID6bzu4+hq+PqCI4=
> > =zZqL
> > -----END PGP SIGNATURE-----
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php

- -- 
Shane
http://www.shanewright.co.uk/
Public key: http://www.shanewright.co.uk/files/public_key.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9h8Q85DXg6dCMBrQRApEbAKCIewL9fgwPT1ey3byL2t2pg1BPRACfWJwN
rUT+B2yFqGn6e2IO3XAGqeM=
=qz1m
-----END PGP SIGNATURE-----

--- End Message ---
--- Begin Message ---
Can't you upgrade to 4.2.3 many bugs were fixed.

--

Nicos - CHAILLAN Nicolas
[EMAIL PROTECTED]
www.WorldAKT.com - Hébergement de sites Internet

"Shane Wright" <[EMAIL PROTECTED]> a écrit dans le message de news:
[EMAIL PROTECTED]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Thanks for the input - but its definately not that; time limit is set to 600
seconds and it dies inside 1 second :(

(i should have added this to the original mail, but it seems to supply the
page but keep the connection open, strange...)

S

On Wednesday 18 September 2002 12:01 am, Tyler Longren wrote:
> How long does the script tend to run before it just "quits"?  Perhaps
> a timeout is set too low in php.ini.
>
> Take a look at max_execution_time in php.ini
>
> tyler
>
> On Tue, 17 Sep 2002 23:14:46 +0100
>
> Shane Wright <[EMAIL PROTECTED]> wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Hi
> >
> > One of my pages opens ~100 files, reads from them, and closes them,
> > (only one file open at a time).
> >
> > The problem is that the page just dies mid-way through execution - no
> > errors, no segfault, it just dies and returns a blank page to the
> > user.  the problem goes away if I reduce the number of files accessed.
> >
> > its a build of PHP 4.1.2 on Linux running as an Apache module,  (if it
> > makes any odds, the configure line is below).
> >
> > I can't see anything on bugs.php.net about this - has anyone seen this
> > before (and, of course, the crucial question; what can I do to fix
> > it?)
> >
> > Any help appreciated,
> >
> > Thanks
> >
> > - --
> > Shane
> > http://www.shanewright.co.uk/
> > Public key: http://www.shanewright.co.uk/files/public_key.asc
> >
> >
> >  './configure' '--with-gd' '--enable-gd-native-ttf'
> >  '--enable-track-vars'
> > '--enable-sysvsem' '--enable-sysvshm' '--enable-calendar'
> > '--with-zlib' '--prefix=/opt/php-4.1'
> > '--with-config-file-path=/usr/local/etc/httpd/conf'
> > '--enable-memory-limit' '--with-db2=/usr' '--with-db3=/usr'
> > '--with-gdbm=/usr' '--with-ndbm=/usr' '--with-dbase' '--with-xml'
> > '--with-expat-dir=/usr' '--enable-debugger' '--enable-ftp'
> > '--with-ttf' '--with-jpeg-dir=/usr' '--enable-bcmath' '--with-openssl'
> >
> > '--enable-trans-sid' '--with-mysql=/usr' '--with-xpm-dir=/usr/X11R6'
> > '--with-png' '--with-png-dir=/usr' '--with-imap' '--with-dom=/usr'
> > '--with-bz2' '--with-curl' '--with-mhash=/usr' '--with-mcrypt=/usr'
> > '--with-pgsql' '--with-gmp' '--with-gettext' '--with-iconv'
> > '--with-kerberos' '--enable-xslt' '--with-xslt-sablot'
> > '--with-freetype-dir=/usr' '--with-apxs=/usr/sbin/apxs'
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.0.7 (GNU/Linux)
> >
> > iD8DBQE9h6lW5DXg6dCMBrQRAhhiAKCIo1xdyyDtx7fT8SO8Xz4bfWOg7QCfdjE3
> > STUVeNEID6bzu4+hq+PqCI4=
> > =zZqL
> > -----END PGP SIGNATURE-----
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php

- --
Shane
http://www.shanewright.co.uk/
Public key: http://www.shanewright.co.uk/files/public_key.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9h8Q85DXg6dCMBrQRApEbAKCIewL9fgwPT1ey3byL2t2pg1BPRACfWJwN
rUT+B2yFqGn6e2IO3XAGqeM=
=qz1m
-----END PGP SIGNATURE-----



--- End Message ---
--- Begin Message ---
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi

my ISP keeps a little behind the curve - sometimes thats a good thing, but 
sometimes not.  :(

We could install our own PHP, but unless this is a known issue that has been 
fixed since I'd rather not risk any others by installing a new version (and 
having to deal with the update issues that causes with my ISPs updates)

Thanks

Shane

On Wednesday 18 September 2002 1:20 am, [EMAIL PROTECTED] wrote:
> Can't you upgrade to 4.2.3 many bugs were fixed.

- -- 
Shane
http://www.shanewright.co.uk/
Public key: http://www.shanewright.co.uk/files/public_key.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9h8gz5DXg6dCMBrQRArHKAJ4w3TjYJpI4ZaRSIi1cXWqOj7DzdwCgu1et
ofTLnvU/I9C4RQMNnpvwXIY=
=JLHf
-----END PGP SIGNATURE-----

--- End Message ---
--- Begin Message ---
Well, yes many issues about that we were fixed on the 4.2.3 and you should
have anyway the latest version of PHP, if your ISP doesn't want to update
it, change.

--

Nicos - CHAILLAN Nicolas
[EMAIL PROTECTED]
www.WorldAKT.com - Hébergement de sites Internet

"Shane Wright" <[EMAIL PROTECTED]> a écrit dans le message de news:
[EMAIL PROTECTED]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi

my ISP keeps a little behind the curve - sometimes thats a good thing, but
sometimes not.  :(

We could install our own PHP, but unless this is a known issue that has been
fixed since I'd rather not risk any others by installing a new version (and
having to deal with the update issues that causes with my ISPs updates)

Thanks

Shane

On Wednesday 18 September 2002 1:20 am, [EMAIL PROTECTED] wrote:
> Can't you upgrade to 4.2.3 many bugs were fixed.

- --
Shane
http://www.shanewright.co.uk/
Public key: http://www.shanewright.co.uk/files/public_key.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9h8gz5DXg6dCMBrQRArHKAJ4w3TjYJpI4ZaRSIi1cXWqOj7DzdwCgu1et
ofTLnvU/I9C4RQMNnpvwXIY=
=JLHf
-----END PGP SIGNATURE-----



--- End Message ---
--- Begin Message ---


I am trying to populate array values and keys from a variable with no
luck.

Lets say I have the following array.

$data1 = array('ONE'=>1,'TWO'=>2,'THREE'=>3,'FOUR'=>4);

And I want to create part of the array with the string below:

$str= "'THREE'=>3, 'FOUR'=>4";
$data2 = array('ONE'=>1,'TWO'=>2,$str);


How can I create $data2 to work the same as $data1.  When I try the
above for $data2 a new key is created ([0]) for $str. And I end up with
...'TWO'=>2, [0] => 'THREE'=>3, 'FOUR'=>4.  It doesn't "interpret" the
variable how I expect it to, instead it see's $str as a value.  I guess
the question is how can I make php use the string literally.

I've tried everything I can think of and I think my head is about to
explode :).  Is it possible to create an Array this way?  Any help is
appreciated!!


print_r($data1):
Array
(
    [ONE] => 1
    [TWO] => 2
    [THREE] => 3
    [FOUR] => 4
)


print_r($data2):
Array
(
    [ONE] => 1
    [TWO] => 2
    [0] => 'THREE'=>3, 'FOUR'=>4
)

--- End Message ---
--- Begin Message ---
Try eval(), like this:

$str= "'THREE'=>3, 'FOUR'=>4";

eval("\$data2 = array('ONE'=>1,'TWO'=>2,$str);");


Max Sullivan wrote:

>I am trying to populate array values and keys from a variable with no
>luck.
>
>Lets say I have the following array.
>
>$data1 = array('ONE'=>1,'TWO'=>2,'THREE'=>3,'FOUR'=>4);
>
>And I want to create part of the array with the string below:
>
>$str= "'THREE'=>3, 'FOUR'=>4";
>$data2 = array('ONE'=>1,'TWO'=>2,$str);
>
>
>How can I create $data2 to work the same as $data1.  When I try the
>above for $data2 a new key is created ([0]) for $str. And I end up with
>...'TWO'=>2, [0] => 'THREE'=>3, 'FOUR'=>4.  It doesn't "interpret" the
>variable how I expect it to, instead it see's $str as a value.  I guess
>the question is how can I make php use the string literally.
>
>I've tried everything I can think of and I think my head is about to
>explode :).  Is it possible to create an Array this way?  Any help is
>appreciated!!
>
>
>print_r($data1):
>Array
>(
>    [ONE] => 1
>    [TWO] => 2
>    [THREE] => 3
>    [FOUR] => 4
>)
>
>
>print_r($data2):
>Array
>(
>    [ONE] => 1
>    [TWO] => 2
>    [0] => 'THREE'=>3, 'FOUR'=>4
>)
>
>
>  
>

--- End Message ---
--- Begin Message ---
php4.2.3 apache mod
linux rh7.2
-------------------

I am trying to add unix system account user via a simple php and shell script
<?
system("/usr/bin/add.sh timtom752002 timtom752002 /home/timtom752002",$r) or die (" $r 
user
creation fail");

print "success";
?>

when i ran add.php on my browser, i get
 254 user creation fail

I created my add.sh file in /usr/bin and I have setuid it:
-rwsr-xr-x    1 root     devel         216 Sep 18 08:54 add.sh

It looks like:
#!/bin/sh

username=$1
password=$2
homedir=$3
# create user
/usr/sbin/useradd -m -d $homedir $username


# change the password
(
echo $password
sleep 1
echo $password
sleep 1
echo $password
)|passwd $username

When I ran the add.sh from the command line, it works ok:
$ /usr/bin/add.sh nnnnn nnnnn /home/nnnnn
Changing password for user nnnnn
passwd: all authentication tokens updated successfully
(i tried login in with uid=nnnnn and passwd=nnnnn and it was ok)

What's wrong with those scripts. It DOESN'T even create the user timtom752002. Please 
help

--
tim


__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com
--- End Message ---
--- Begin Message ---
you need to make sure that the web has permission to use that file .. my
guess is it don't have permission hence why you can run add.sh from the
command line (where your not your web user I'm assuming).

> -----Original Message-----
> From: tim tom [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, 18 September 2002 10:56 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] adding unix account via system command
>
>
> php4.2.3 apache mod
> linux rh7.2
> -------------------
>
> I am trying to add unix system account user via a simple php and
> shell script
> <?
> system("/usr/bin/add.sh timtom752002 timtom752002
> /home/timtom752002",$r) or die (" $r user
> creation fail");
>
> print "success";
> ?>
>
> when i ran add.php on my browser, i get
>  254 user creation fail
>
> I created my add.sh file in /usr/bin and I have setuid it:
> -rwsr-xr-x    1 root     devel         216 Sep 18 08:54 add.sh
>
> It looks like:
> #!/bin/sh
>
> username=$1
> password=$2
> homedir=$3
> # create user
> /usr/sbin/useradd -m -d $homedir $username
>
>
> # change the password
> (
> echo $password
> sleep 1
> echo $password
> sleep 1
> echo $password
> )|passwd $username
>
> When I ran the add.sh from the command line, it works ok:
> $ /usr/bin/add.sh nnnnn nnnnn /home/nnnnn
> Changing password for user nnnnn
> passwd: all authentication tokens updated successfully
> (i tried login in with uid=nnnnn and passwd=nnnnn and it was ok)
>
> What's wrong with those scripts. It DOESN'T even create the user
> timtom752002. Please help
>
> --
> tim
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Autos - Get free new car price quotes
> http://autos.yahoo.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Dear Pete,
Yes, apache runs as nobody. But I have setuid add.sh. Wouldn't that be sufficient ?

--
tim

--- Peter Houchin <[EMAIL PROTECTED]> wrote:
> you need to make sure that the web has permission to use that file .. my
> guess is it don't have permission hence why you can run add.sh from the
> command line (where your not your web user I'm assuming).
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com
--- End Message ---
--- Begin Message ---
I am not sure to be totally honest ...  but i would have thought you setuid
on add.sh to allow it to add the users but i don't think it would work for
user nobody. ..what if you tried something like this

user nobody (Apache)
calls add.sh (initially started by user nobody)
add.sh changes user to say user admin
useradd runs
add.sh exits user admin
add.sh ends


either that or make sure user nobody is a member of the devel group.. but
that could lead to security issues.


> -----Original Message-----
> From: tim tom [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, 18 September 2002 12:14 PM
> To: Peter Houchin; [EMAIL PROTECTED]
> Subject: RE: [PHP] adding unix account via system command
>
>
> Dear Pete,
> Yes, apache runs as nobody. But I have setuid add.sh. Wouldn't
> that be sufficient ?
>
> --
> tim
>
> --- Peter Houchin <[EMAIL PROTECTED]> wrote:
> > you need to make sure that the web has permission to use that file .. my
> > guess is it don't have permission hence why you can run add.sh from the
> > command line (where your not your web user I'm assuming).
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Autos - Get free new car price quotes
> http://autos.yahoo.com
>

--- End Message ---
--- Begin Message ---
It's a shell script, and your shell drops root privileges. Use a shell 
that doesn't or use a C-wraper.

tim tom wrote:

>Dear Pete,
>Yes, apache runs as nobody. But I have setuid add.sh. Wouldn't that be sufficient ?
>
>--
>tim
>
>--- Peter Houchin <[EMAIL PROTECTED]> wrote:
>  
>
>>you need to make sure that the web has permission to use that file .. my
>>guess is it don't have permission hence why you can run add.sh from the
>>command line (where your not your web user I'm assuming).
>>
>>    
>>
>
>
>__________________________________________________
>Do You Yahoo!?
>Yahoo! Autos - Get free new car price quotes
>http://autos.yahoo.com
>
>  
>

--- End Message ---
--- Begin Message ---
I would like to know how to conditionally included a file based on the
document location.

The purpose is for placement of location-specific navigation menus.

I'm not interested in DHTML hierarchical drop-down menus, rather inserting
ready made HTML files using perhaps (?) DOCUMENT_URI (?) and error checking
logic.

----------------------------------------------------------------------------
EXAMPLE

If DOCUMENT_URI is "/" (home) then the following file included:

URL: <http://www.globalhemp.com/includes/apple.html>

If DOCUMENT_URI is "/quicktime/" then the following file included:

URL: <http://www.globalhemp.com/includes/quicktime.html>

If DOCUMENT_URI is "/quicktime/download/" then the following file included:

URL: <http://www.globalhemp.com/includes/quicktime_download.html>
----------------------------------------------------------------------------

The error checking logic would be for child directories that don't have
their own include file and thus would use a parent directory include file.
If a parent directory file doesn't exist, it would include the top-level
(home) include file.

The closest PHP example that I have found thus far follows:

----------------------------------------------------------------------------
[INCOMPLETE] PHP CONDITIONAL INCLUDE EXAMPLE
Extracted from: <http://www.jwweb.com/20010629.html>

<?php
if ($location == "quicktime") {
include("quicktime.inc");
if ($location == "quicktime/download") {
include("download.inc");
} else {
include("home.inc");
}
?>
----------------------------------------------------------------------------

THANKS!

Eric C. Pollitt, Founder
401 E. Illinois Ave.
Peoria, IL 61603
Global Hemp - Portal to the hemp community
http://www.globalhemp.com/

Create like a god.  Command like a king.  Work like a slave!
-- Constantin Brancusi

--- End Message ---
--- Begin Message ---
switch($DOCUMENT_URI) {
    case '/':
        include(" watch you want");
        break;
    case ........
....
}

Eric C. Pollitt wrote:

>I would like to know how to conditionally included a file based on the
>document location.
>
>The purpose is for placement of location-specific navigation menus.
>
>I'm not interested in DHTML hierarchical drop-down menus, rather inserting
>ready made HTML files using perhaps (?) DOCUMENT_URI (?) and error checking
>logic.
>
>----------------------------------------------------------------------------
>EXAMPLE
>
>If DOCUMENT_URI is "/" (home) then the following file included:
>
>URL: <http://www.globalhemp.com/includes/apple.html>
>
>If DOCUMENT_URI is "/quicktime/" then the following file included:
>
>URL: <http://www.globalhemp.com/includes/quicktime.html>
>
>If DOCUMENT_URI is "/quicktime/download/" then the following file included:
>
>URL: <http://www.globalhemp.com/includes/quicktime_download.html>
>----------------------------------------------------------------------------
>
>The error checking logic would be for child directories that don't have
>their own include file and thus would use a parent directory include file.
>If a parent directory file doesn't exist, it would include the top-level
>(home) include file.
>
>The closest PHP example that I have found thus far follows:
>
>----------------------------------------------------------------------------
>[INCOMPLETE] PHP CONDITIONAL INCLUDE EXAMPLE
>Extracted from: <http://www.jwweb.com/20010629.html>
>
><?php
>if ($location == "quicktime") {
>include("quicktime.inc");
>if ($location == "quicktime/download") {
>include("download.inc");
>} else {
>include("home.inc");
>}
>?>
>----------------------------------------------------------------------------
>
>THANKS!
>
>Eric C. Pollitt, Founder
>401 E. Illinois Ave.
>Peoria, IL 61603
>Global Hemp - Portal to the hemp community
>http://www.globalhemp.com/
>
>Create like a god.  Command like a king.  Work like a slave!
>-- Constantin Brancusi
>
>
>  
>

--- End Message ---
--- Begin Message ---
Hello Rudolf,
Thank you for responding to my post, I really appreciate it.

I ran the script you sent me, and then I tried looking up the syntax to try
to figure out what it means. As it would be pointless for me just to take
suggestions that people send me and then not learn what they mean. The
resulkt of your code does in fact alphabatize the teams in the select list,
however there is a little problem with the end result.

your code:

<?php

  include ("C:\Program
Files\EasyPHP\www\florentiaviola.com\control\config.php");

  $fd = fopen ($teams, "r");
  while (!feof ($fd))
  {
   $list = fgets($fd, 4096);
   $squads = explode("|", $list);
   $alphabetical[] = $squads[1];
  }

   sort ($alphabetical);
   reset ($alphabetical);

   for ($i = 0; $i <= count($alphabetical) - 1; $i++)
   {
   echo '<OPTION VALUE="'.
$alphabetical[$i][0].'">'.$alphabetical[$i].'</OPTION>'."\n";
   }
   fclose ($fd);


?>

returns the follwoing html:
<OPTION VALUE="A">Aglianese</OPTION>
<OPTION VALUE="B">Brescello</OPTION>
<OPTION VALUE="C">Casteldisangro</OPTION>
<OPTION VALUE="C">Castelnuovo</OPTION>
<OPTION VALUE="F">Fano</OPTION>
<OPTION VALUE="F">Florentia Viola</OPTION>
<OPTION VALUE="F">Forlì</OPTION>
<OPTION VALUE="G">Grosseto</OPTION>
<OPTION VALUE="G">Gualdo</OPTION>


It is returning the first letter of $squads[1]. so the "id variable is
getting lost.That variable is $squads[0]. So in effect that vairable is
getting "lost" because when i modify the line

echo '<OPTION VALUE="'.
$alphabetical[$i][0].'">'.$alphabetical[$i].'</OPTION>'."\n";

to read

echo '<OPTION VALUE="'. $squads[0].'">'.$alphabetical[$i].'</OPTION>'."\n";

then the HTML output becomes

<OPTION VALUE="19">Aglianese</OPTION>
<OPTION VALUE="19">Brescello</OPTION>
<OPTION VALUE="19">Casteldisangro</OPTION>
<OPTION VALUE="19">Castelnuovo</OPTION>
<OPTION VALUE="19">Fano</OPTION>
<OPTION VALUE="19">Florentia Viola</OPTION>
<OPTION VALUE="19">Forlì</OPTION>
<OPTION VALUE="19">Grosseto</OPTION>
<OPTION VALUE="19">Gualdo</OPTION>

In other words what I am trying to do is something to the effect of
$alphabetical = $squads[1][0]. Then I want to sort that only by $squads[1].
When the html is returned, I want to be able to echo the $squads[0] as the
Value of the select dropdown.

Thanks again,
-Tree


--- End Message ---
--- Begin Message ---
I would do it this way (it fails if some names are same):

Chad Winger wrote:

>Hello Rudolf,
>Thank you for responding to my post, I really appreciate it.
>
>I ran the script you sent me, and then I tried looking up the syntax to try
>to figure out what it means. As it would be pointless for me just to take
>suggestions that people send me and then not learn what they mean. The
>resulkt of your code does in fact alphabatize the teams in the select list,
>however there is a little problem with the end result.
>
>your code:
>
><?php
>
>  include ("C:\Program
>Files\EasyPHP\www\florentiaviola.com\control\config.php");
>  
>
>  $fd = fopen ($teams, "r");
>  while (!feof ($fd))
>  {
>   $list = fgets($fd, 4096);
>   $squads = explode("|", $list);
>   $alphabetical[$squads[1]] = $squads[0];
>  }
>   fclose ($fd);
>
>   ksort ($alphabetical);
>  
>
>   foreach ($alphabetical as $name => $id)
>   {
>   echo '<OPTION VALUE="'.$id.'">'.$name.'</OPTION>'."\n";
>   }
>
>
>
>?>
>
>returns the follwoing html:
><OPTION VALUE="A">Aglianese</OPTION>
><OPTION VALUE="B">Brescello</OPTION>
><OPTION VALUE="C">Casteldisangro</OPTION>
><OPTION VALUE="C">Castelnuovo</OPTION>
><OPTION VALUE="F">Fano</OPTION>
><OPTION VALUE="F">Florentia Viola</OPTION>
><OPTION VALUE="F">Forlě</OPTION>
><OPTION VALUE="G">Grosseto</OPTION>
><OPTION VALUE="G">Gualdo</OPTION>
>
>
>It is returning the first letter of $squads[1]. so the "id variable is
>getting lost.That variable is $squads[0]. So in effect that vairable is
>getting "lost" because when i modify the line
>
>echo '<OPTION VALUE="'.
>$alphabetical[$i][0].'">'.$alphabetical[$i].'</OPTION>'."\n";
>
>to read
>
>echo '<OPTION VALUE="'. $squads[0].'">'.$alphabetical[$i].'</OPTION>'."\n";
>
>then the HTML output becomes
>
><OPTION VALUE="19">Aglianese</OPTION>
><OPTION VALUE="19">Brescello</OPTION>
><OPTION VALUE="19">Casteldisangro</OPTION>
><OPTION VALUE="19">Castelnuovo</OPTION>
><OPTION VALUE="19">Fano</OPTION>
><OPTION VALUE="19">Florentia Viola</OPTION>
><OPTION VALUE="19">Forlě</OPTION>
><OPTION VALUE="19">Grosseto</OPTION>
><OPTION VALUE="19">Gualdo</OPTION>
>
>In other words what I am trying to do is something to the effect of
>$alphabetical = $squads[1][0]. Then I want to sort that only by $squads[1].
>When the html is returned, I want to be able to echo the $squads[0] as the
>Value of the select dropdown.
>
>Thanks again,
>-Tree
>
>
>  
>

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Chad Winger [mailto:[EMAIL PROTECTED]]
> Sent: 18 September 2002 02:32
> 
> however there is a little problem with the end result.
> 
> your code:
> 
> <?php
> 
>   include ("C:\Program
> Files\EasyPHP\www\florentiaviola.com\control\config.php");
> 
>   $fd = fopen ($teams, "r");
>   while (!feof ($fd))
>   {
>    $list = fgets($fd, 4096);
>    $squads = explode("|", $list);
>    $alphabetical[] = $squads[1];
>   }
> 
>    sort ($alphabetical);
>    reset ($alphabetical);
> 
>    for ($i = 0; $i <= count($alphabetical) - 1; $i++)
>    {
>    echo '<OPTION VALUE="'.
> $alphabetical[$i][0].'">'.$alphabetical[$i].'</OPTION>'."\n";
>    }
>    fclose ($fd);
> 
> 
> ?>

The problem with this script is it only sorts the team names, without
re-ordering the other columns of your array to match.  And the notation
$alphabetical[$i][0] is actually accessing the first character of the string
(tema name) in $alphabetical[$i] -- hence the result you see.

What you need to do is create an array or arrays containing all the content
you need to sort, and then sort them in parallel based on the team names.

My instinct would be to build a nested array of your values thusly:

   while (!feof ($fd))
   {
    $list = fgets($fd, 4096);
    $squads[] = explode("|", $list);
   }

which would build an array like this:

   $squads[0][0] => 01
   $squads[0][1] => Brescello
   $squads[0][2] => stadium
   $squads[0][3] => city
   $squads[1][0] => 02
   $squads[1][1] => Aglianese
   $squads[1][2] => stadium
   $squads[1][3] => city
   $squads[2][0] => 03
   $squads[2][1] => Casteldisangro
   $squads[2][2] => stadium
   $squads[2][3] => city

etc.

However, a little research in the PHP online manual looking for sorting
functions reveals that there's no simple function to sort this array the way
you want. There are two ways around this:

1. Build your arrays differently; whilst this is possible, it needs more
work and is not nearly as elegant (unless you need them this way for other
stuff in your script).  I'll leave this as an exercise for the reader, as
there at least 2 possible answers, but the sorting functions you might use
are asort() or array_multisort().

2. Use a more complex sorting method that sorts the above array as you want.
This is not actually as hard as it sounds, as there are several user notes
in the online manual under the entry for usort() that address exactly this
problem.  Basically, you need to define a function that says how to compare
two $squads[] rows for sorting -- in this case, by comparing the
$squads[][1] entries, so:

123456789*123456789*123456789*123456789*123456789*123456789*123456789*123456
  function squad_compare($a, $b) // $a, $b each passed a $squads[] row
  {
     return strcasecmp($a[1], $b[1]);  // returns <0 if $a sorts first,
                                       // 0 if equal, >0 if $b sorts first
                                       // (case-INsensitive comparison)
  }

and then use this in a usort() (sort with user-defined comparison) call:

  usort($squads, 'squad_compare');

I've broken this down into component steps for easier understanding, but you
can actually do it all-in-one if you don't need to use the compare function
elsewhere; again, this is adapted from a user note on the usort() manual
page:

   usort($squads, create_function('$a,$b', 'return strcasecmp($a[1],
$b[1])'));

Finally, you can iterate through the results and generate your form:

  foreach($squads as $squad_info):
    echo '<OPTION
VALUE="'.$squad_info[0].'">'.$squad_info[1].'</OPTION>'."\n";
  endforeach;

Hope this helps somewhat!

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 
--- End Message ---
--- Begin Message ---
Can you use PHP to add appts to my microsoft outlook calendar or open up a
document in ms word?




--- End Message ---
--- Begin Message ---
Look at the COM support (never have worked with it but it should be what 
you are looking for)

Matthew Tapia wrote:

>Can you use PHP to add appts to my microsoft outlook calendar or open up a
>document in ms word?
>
>
>
>
>
>  
>

--- End Message ---
--- Begin Message ---
In article <[EMAIL PROTECTED]>, eurleif@buyer-
brokerage.com says...
> I'm looking for a regex which splits a string by commas, but only if the 
> comma is not in parenthesis.   I know I'm being lazy and should write it 
> myself, but that's just it... I'm lazy!

Well, as it happens I'm too lazy to write it for you :-)

-- 
David Robley
Temporary Kiwi!

Quod subigo farinam
--- End Message ---
--- Begin Message ---
Hi there. I'm trying to come up with a way to do
PATH_INFO urls without having to call a script. Let me
explain.

I know how to make it work with a url like this:

http://foo.com/bar.php/arg1/arg2/etc

or even:

http://foo.com/bar/arg1/arg2/etc

What I'm trying to figure out is how to make it call
index.php without specifying it, like this:

http://foo.com/arg1/arg2/etc

Any pointers?

Thanks.


__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com
--- End Message ---
--- Begin Message ---
Fwd-ing to correct list ..


> Hi
>
> I hope someone can help me
>
> I have made a program with a servercomponent
> And this program connects to a PHP script on  a webserver
> and the script makes a socket connection to this servercomponent
>
> and I want that this script logs into a database (or whatever) the
logintime
> and when the program disconnects
>
> it works fine but if my internetconnection interrupts (for example my
> provider makes a IP change) the script doesn't recognize it ....
>
> what can I do??
>
> my script:
>
> $fp = fsockopen($ip, $port, &$err_num, &$err_msg, 10);
>
> if ($fp)
> {
>    $daten = "GET / HTTP/1.0\r\nUser-Agent: TestClient\r\n\r\n";
>    fputs($fp, $daten);
>
> // Database Entry >ONLINE!<
>
>    while (!feof($fp))
>    {
>     $zwdaten .= fgets($fp, 1);
>    }
>
> // Database Entry >OFFLINE!<
>
> }
>
> MFG
>    Günther Leitgeb
>    [EMAIL PROTECTED]             [EMAIL PROTECTED]
>    [EMAIL PROTECTED] [EMAIL PROTECTED]
>    ICQ: 104677570
>
>
>
> --
> PHP-GTK General Mailing List (http://gtk.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Hi all,

I've never combined PHP with Flash, but I do know there's some
possibilities. I'm wondering if I can make a dynamic-PHP-site which
controls Flash. I need the administrator to be able to upload a new product
to a DB, and then be seen by the visitors in Flash... is this possible?

I want to do something like www.rolex.com but don't want to make new pages
every time a new product is added... Is this possble? Where can I find the
documentation?

Thanks in advance,

César Aracena
On Dial-Up

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .


--- End Message ---
--- Begin Message ---
php.net/ming

On Wed, 18 Sep 2002, [EMAIL PROTECTED] wrote:

> Hi all,
>
> I've never combined PHP with Flash, but I do know there's some
> possibilities. I'm wondering if I can make a dynamic-PHP-site which
> controls Flash. I need the administrator to be able to upload a new product
> to a DB, and then be seen by the visitors in Flash... is this possible?
>
> I want to do something like www.rolex.com but don't want to make new pages
> every time a new product is added... Is this possble? Where can I find the
> documentation?
>
> Thanks in advance,
>
> César Aracena
> On Dial-Up
>
> --------------------------------------------------------------------
> mail2web - Check your email from the web at
> http://mail2web.com/ .
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--- End Message ---
--- Begin Message ---
Hi,

Wednesday, September 18, 2002, 7:15:36 AM, you wrote:

DM> Is there a "clean" way to make use of PHP builtins that use callbacks and 
DM> point those call backs to a method inside the class/object:

DM> A good example would be:

DM> ...

DM> class XMLClass {

DM>   var $parser;

DM>   function XMLClass() {
DM>     $this->parser = xml_parser_create();
DM>     xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, TRUE);
DM>     xml_set_element_handler($this->parser, "$this->start", "$this->end");
DM>     xml_set_character_data_handler($this->parser, "$this->data");
DM>   }

DM>   function goodbye() { // a manual destructor
DM>     xml_parser_free($this->parser);
DM>     // other things possibly too
DM>   }


DM>   function start($p2, $name, $attr) {
DM>     // do things here
DM>   }

DM>   function data($p2, $data) {
DM>     // do some more here
DM>   }

DM>   function end($p2, $name) {
DM>     // do even more things here
DM>   }

DM>   [... and so on ...]

DM> ...

DM> But since there is no way to set a callback to "$this->[function_name]" one 
DM> must create a global function that uses a global object and passes things to 
DM> the method inside the class..

DM> Is the a way to address this? or perhaps a better way to deal with callback 
DM> function names?

DM> --Douglas Marsh


Here is a skeleton of a parser class, note the uses of '&' to avoid
generating copies of the object:

class xml_parser {
        var $xml_parser;
// constructor
        function xml_parser() {
          $this->xml_parser = xml_parser_create();
          xml_set_element_handler($this->xml_parser, 
array(&$this,"start_element"),array(&$this,"end_element"));
          
xml_set_character_data_handler($this->xml_parser,array(&$this,"character_data"));
        }
        function character_data($parser, $data) {

        }
        function start_element($parser, $name, $attrs) {
                  
        }
        function end_element($parser, $name) {

        }
        function parse() {
          
        }
}
//usage
$xml =& new xml_parser();

-- 
regards,
Tom

--- End Message ---
--- Begin Message ---

Yeah, my brain is broke enough already,
i'll just give the class an optional 'name' property.

Thanks all!

"Will Steffen" <[EMAIL PROTECTED]> wrote in message
003101c25e34$2a049950$8000a8c0@william">news:003101c25e34$2a049950$8000a8c0@william...
> Hehe why break your brain- give the class an id property - then you can
> have a getid method and do something like this
>
> $id = $this->getid();
> $this->fpLog = fopen("$id.log","w+");
>
> get_object_vars only seems to return properties so its not gonna help
> you.
>
> I'm currently working on an object thang as well and what ive done where
> I have whole bunch of similar objects is to chuck them into a name=value
> array as they get created so I can find them and fiddle with them again.
> I have no idea if that helps you, or if its even good coding practice
> (formal training - wots that?)
>
> hey im also a n00b so don't take my word on it  - actual mileage may
> vary :-P



--- End Message ---
--- Begin Message ---
Check out the source of phpMyAdmin -- they do this, and do it well :)

Also, check out the mysql_* functions in the manual -- field_type for
example.

Justin


on 18/09/02 4:33 AM, Vincent Stoessel ([EMAIL PROTECTED]) wrote:

> Hello,
> Are there any new scripts out there that will build an html from based
> on the schema of a database (mysql, postgresql). hate to be lazy but
> this is getting repetative.

--- End Message ---
--- Begin Message ---
Messaging Solution
~~~~~~~~~~~~~~~~~~~~
I want to develop a web-based Messaging System where the clients needs the messages 
and server keeps sending the messages based on Technical Request from the client.

I need to write a php script for responding to the client's Request.

How do I go about this job, is there already PHP Classes or Open Source Solution Ready 
which I might take and go about this job or I need to do this from the scratch.

Kindly guide me on this.

karthikeyan.

  
--- End Message ---
--- Begin Message ---
You are very general, what you are asking for is all PHP is about.

karthikeyan wrote:

>Messaging Solution
>~~~~~~~~~~~~~~~~~~~~
>I want to develop a web-based Messaging System where the clients needs the messages 
>and server keeps sending the messages based on Technical Request from the client.
>
>I need to write a php script for responding to the client's Request.
>
>How do I go about this job, is there already PHP Classes or Open Source Solution 
>Ready which I might take and go about this job or I need to do this from the scratch.
>
>Kindly guide me on this.
>
>karthikeyan.
>
>  
>
>  
>

--- End Message ---
--- Begin Message ---
I'm looking for 1 or 2 people with good PHP/MySQL experience in the Los Angeles area.

I have a few steady projects that pay $20/hr.
(All of them 100% PHP/MySQL.  All of them fun/non-corporate music-based sites.)

If interested, please email my personal address:  "[EMAIL PROTECTED]"
Include your contact info & any sites/projects you've worked on.

Thanks!

--- End Message ---
--- Begin Message ---
Yeah, mail() again...

I want to disable the default mail command and replace it with my own.
I've written a function that talks directly to my SMTP server, however, I'd
rather not go thru every single script on my server and change all the
mail() functions.

Any ideas?

Cheers,
Liam


--- End Message ---
--- Begin Message ---
Try to set it in "disable_functions", it may help, or may not. Otherwise 
disable it in php sources or even better regexp your scripts to change 
mail to something else.

Liam wrote:

>Yeah, mail() again...
>
>I want to disable the default mail command and replace it with my own.
>I've written a function that talks directly to my SMTP server, however, I'd
>rather not go thru every single script on my server and change all the
>mail() functions.
>
>Any ideas?
>
>Cheers,
>Liam
>
>
>
>  
>

--- End Message ---
--- Begin Message ---
Try direct connection to the server to see the response it sends, you 
may also try to send header("HTTP/1.0 302 Found") and see if that helps.
What browsers does it happens to?

jana konickova wrote:

>I have the php script with the command
>Header("Location: https://$SERVER_NAME$path";);
>which redirect from the script "file1.php" to the script "file2.php".
>If I fill the form in the www page "file1.php" and click the Submit button, 
>the script "file1.php" save the information to database and then redirect to 
>the page "file2.php".
>This redirecting  is functional, but not always. In some www browser the 
>first redirecting not work, and if I return to the www page "file1.php" and 
>if I click the Submit button again, the redirecting  working.
>
>Do you have some help, please?
>
>(Using Linux,  Apache/1.3.23 & PHP 4.1.2)
>
>Much thanks!
>
>Jana Konickova
>
>  
>

--- End Message ---
--- Begin Message ---
 Hi, I have a table table1, with a column "Duration" time type(ex 00:12:30)
I want to make in PHP a sql selection:
SELECT * from table1 WHERE condition, and after that, to make sum of values
of column "Duration" and display it.
Any Help?

How to transform time in seconds, with php functions?
tx

--- End Message ---
--- Begin Message ---
Hello,

Try this:
SELECT SUM(duration) AS summ, ..., ..., ..., FROM table1 WHERE condition
Hope it will help ya!

Regards,
Denis Basta.

"Adi" <[EMAIL PROTECTED]> wrote in message
008701c25ef1$01d94260$9600a8c0@adi">news:008701c25ef1$01d94260$9600a8c0@adi...
Hi, I have a table table1, with a column "Duration" time type(ex 00:12:30)
I want to make in PHP a sql selection:
SELECT * from table1 WHERE condition, and after that, to make sum of values
of column "Duration" and display it.
Any Help?

How to transform time in seconds, with php functions?
tx




--- End Message ---
--- Begin Message ---
won't help, it's forbidden to mix aggregate columns with non aggregate 
without a group by clause. Make your first query and then the sum.

Denis Basta wrote:

>Hello,
>
>Try this:
>SELECT SUM(duration) AS summ, ..., ..., ..., FROM table1 WHERE condition
>Hope it will help ya!
>
>Regards,
>Denis Basta.
>
>"Adi" <[EMAIL PROTECTED]> wrote in message
>008701c25ef1$01d94260$9600a8c0@adi">news:008701c25ef1$01d94260$9600a8c0@adi...
>Hi, I have a table table1, with a column "Duration" time type(ex 00:12:30)
>I want to make in PHP a sql selection:
>SELECT * from table1 WHERE condition, and after that, to make sum of values
>of column "Duration" and display it.
>Any Help?
>
>How to transform time in seconds, with php functions?
>tx
>
>
>
>
>
>  
>

--- End Message ---
--- Begin Message ---
if your data is in UNIX TIMESTAMP format:

$result = mysql_query("select * from table1;",$db);
while ($row = mysql_fetch_array($result)){
// convert seconds from epoch into human date //
$data[] = date("Hi",mktime(0,0,$row['duration'],1,1,1970));
}

so I guess using mktime to convert DATE into unix timestamp

///mktime to recreate the unix timestamp
$result = mysql_query("select * from table1;",$db);
while ($row = mysql_fetch_array($result)){
$data[] =  mktime($hours ,$minutes, $seconds,$month ,$day,$year);
}

to sum the row you would need to add something like this.

$result = mysql_query("select * from table1;",$db);
while ($row = mysql_fetch_array($result)){
$var = $row['duration']
$sum = $var + $sum
}
echo $sum

but I'm sure other people have much better ways of doing it:) it's a bit
early in the morning for me....
hope this helps.
Warren 

-----Original Message-----
From: adi [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 18, 2002 9:55 AM
To: PHP-General
Subject: [PHP] time to seconds


 Hi, I have a table table1, with a column "Duration" time type(ex
00:12:30)
I want to make in PHP a sql selection:
SELECT * from table1 WHERE condition, and after that, to make sum of
values
of column "Duration" and display it.
Any Help?

How to transform time in seconds, with php functions?
tx

Attachment: smime.p7s
Description: application/pkcs7-signature

--- End Message ---
--- Begin Message ---
Hi people,

I have a table with a column called ID (auto-increment).
Is it possible to know the value of ID, right after inserting 
a row? 

I'm using postgresql.

Thanks.

Sincerely,
Faisal

______________________________________

--- End Message ---
--- Begin Message ---
Hi there.

You can use the function mysql_insert_id( [link id] ).

regards

Scott

Faisal Abdullah wrote:
> Hi people,
> 
> I have a table with a column called ID (auto-increment).
> Is it possible to know the value of ID, right after inserting 
> a row? 
> 
> I'm using postgresql.
> 
> Thanks.
> 
> Sincerely,
> Faisal
> 
> ______________________________________
> 
> 


-- 
//--------------------------------------------//
// Scott Houseman                             //
// Jam Warehouse http://www.jamwarehouse.com/ //
// Smart Business Innovation                  //
// +27 21 4477440 / +27 82 4918021            //
//--------------------------------------------//

--- End Message ---
--- Begin Message ---
Scott Houseman wrote:
> Hi there.
> 
> You can use the function mysql_insert_id( [link id] ).
> 
>> I'm using postgresql.

Not if you're using PostGreSQL

Grtz Erwin
--- End Message ---
--- Begin Message ---
As he uses postgresql, he should use *pg_last_oid()*

Scott Houseman wrote:

> Hi there.
>
> You can use the function mysql_insert_id( [link id] ).
>
> regards
>
> Scott
>
> Faisal Abdullah wrote:
>
>> Hi people,
>>
>> I have a table with a column called ID (auto-increment).
>> Is it possible to know the value of ID, right after inserting a row?
>> I'm using postgresql.
>>
>> Thanks.
>>
>> Sincerely,
>> Faisal
>>
>> ______________________________________
>>
>>
>
>

--- End Message ---
--- Begin Message ---
not on postgreSQL :)

Justin


on 18/09/02 7:24 PM, Scott Houseman ([EMAIL PROTECTED]) wrote:

> Hi there.
> 
> You can use the function mysql_insert_id( [link id] ).
> 
> regards
> 
> Scott
> 
> Faisal Abdullah wrote:
>> Hi people,
>> 
>> I have a table with a column called ID (auto-increment).
>> Is it possible to know the value of ID, right after inserting
>> a row? 
>> 
>> I'm using postgresql.
>> 
>> Thanks.
>> 
>> Sincerely,
>> Faisal
>> 
>> ______________________________________
>> 
>> 
> 

--- End Message ---
--- Begin Message ---
I tried that. It gives me 24807, instead of 5.
Or is oid is a reference to something else, which would 
lead me to the '5' i'm looking for?

-- snip snip --

if($result = pg_exec($db, $sql))
    {
        $query = "success";
        echo "oid : " .pg_last_oid($result);
        }

-- snip snip --

Sincerely,
Faisal

-----Original Message-----
From: Marek Kilimajer [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 18, 2002 5:42 PM
To: PHP
Subject: Re: [PHP] Auto-increment value


As he uses postgresql, he should use *pg_last_oid()*

Scott Houseman wrote:

> Hi there.
>
> You can use the function mysql_insert_id( [link id] ).
>
> regards
>
> Scott
>
> Faisal Abdullah wrote:
>
>> Hi people,
>>
>> I have a table with a column called ID (auto-increment).
>> Is it possible to know the value of ID, right after inserting a row?
>> I'm using postgresql.
>>
>> Thanks.
>>
>> Sincerely,
>> Faisal
>>
>> ______________________________________
>>
>>
>
>


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

______________________________________

--- End Message ---
--- Begin Message ---
It means the $_GET or $_POST doesn't exist, just verify that it exists.
a GET is on your URL like lala.php?irc=1 and $_GET['irc] = 1;
a POST is on your form and it will appear like $_POST['lol'].

Nicos - CHAILLAN Nicolas
[EMAIL PROTECTED]
www.WorldAKT.com - Hébergement de sites Internet

----- Original Message -----
From: <[EMAIL PROTECTED]>
Newsgroups: php.notes
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 18, 2002 10:42 AM
Subject: note 25286 added to function.mb-strcut


> I always receive the error message:
>
> "Call to underfined function:..."
>
> when call this kind ( multiby string ) of function
> --
> http://www.php.net/manual/en/function.mb-strcut.php
> http://master.php.net/manage/user-notes.php?action=edit+25286
> http://master.php.net/manage/user-notes.php?action=delete+25286
> http://master.php.net/manage/user-notes.php?action=reject+25286
>

--- End Message ---

Reply via email to