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-help_at_lists.php.net
Date: Thu Oct 03 2002 - 00:47:04 CDT

  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

    php-general Digest 3 Oct 2002 05:47:04 -0000 Issue 1621

    Topics (messages 118618 through 118696):

    getImageSize
            118618 by: Dan McCullough
            118682 by: tuxen

    Re: How can I check for variances in spelling within form text input fields?
            118619 by: Debbie Dyer
            118628 by: Chris Hewitt
            118688 by: Justin French

    Inheritance and a class function: on what class was it called?
            118620 by: Nick Eby
            118627 by: Debbie Dyer
            118630 by: Nick Eby
            118631 by: Debbie Dyer
            118635 by: Nick Eby
            118662 by: Debbie Dyer
            118665 by: Rasmus Lerdorf
            118668 by: Nick Eby
            118670 by: Rasmus Lerdorf
            118672 by: Debbie Dyer
            118673 by: Nick Eby

    Re: Getting users IP address into a variable.
            118621 by: Chris Hewitt
            118623 by: Webmaster MBTRADINGCO

    Math problem (222)
            118622 by: tony.tabzilla.com
            118626 by: Philip Hallstrom
            118629 by: Jome
            118632 by: Chris Hewitt

    upgrading script from using GLOBALS
            118624 by: Nicole Lallande

    stat failed for Resource ?
            118625 by: new.php.net

    PHP User Name on Win2000
            118633 by: [-^-!-%-
            118634 by: Ionut Ciocirlan
            118677 by: John W. Holmes

    extract domain name from a URL
            118636 by: Joseph Szobody
            118640 by: Joseph Szobody
            118689 by: Justin French

    Setting date fields in mysql queries
            118637 by: Brad Harriger
            118638 by: Matt Schroebel
            118639 by: Jay Blanchard
            118653 by: Frank

    BAD FILE DESCRIPTOR
            118641 by: Robert Samuel White

    Help with Numbers
            118642 by: Christopher J. Crane
            118644 by: Rasmus Lerdorf
            118648 by: Christopher J. Crane

    Paging HOWTO for PHP n' MYSQL
            118643 by: Francisco Vaucher
            118646 by: Rasmus Lerdorf
            118676 by: John W. Holmes

    Help with CHdir
            118645 by: Nokar
            118647 by: Rasmus Lerdorf

    addslashes and remove slashes.
            118649 by: Anil Garg
            118650 by: Rasmus Lerdorf

    Global variables
            118651 by: Anna Gyor
            118658 by: Kevin Stone
            118675 by: John W. Holmes
            118678 by: Peter J. Schoenster
            118690 by: Tom Rogers

    (bad file descriptor) is a BUG
            118652 by: Robert Samuel White

    counting number of records in a MySQL table; how do I get the result?
            118654 by: DonPro
            118655 by: Kevin Stone
            118656 by: Rasmus Lerdorf
            118674 by: John W. Holmes
            118686 by: Jeff Bluemel

    MORE Problems with PHP as CGI and Flash !!!!!!!!!!
            118657 by: Rebekah Garner
            118681 by: antis0cial d0rk

    Re: eregi_replace / preg_match_all
            118659 by: Jennifer Swofford

    no errors ?
            118660 by: gamin
            118663 by: Jason Reid
            118664 by: Robert Cummings
            118667 by: gamin
            118679 by: Jason Young
            118680 by: Paul Nicholson

    Some mcrypt function don't seem to work.
            118661 by: Scott Fletcher

    Server API
            118666 by: Alex Shi

    reg exp matching/replacing
            118669 by: Jennifer Swofford

    Re: Quick question.
            118671 by: David Freeman

    Trouble with understanding arrays
            118683 by: Christopher J. Crane
            118696 by: Andy Crain

    Re: Access denied to php files in Netscape 6
            118684 by: Chris Nielsen
            118685 by: Chris Nielsen

    Re: counting number of records in a MySQL table; how do I get
            118687 by: Dan Koken

    Incrementing the value
            118691 by: Uma Shankari T.
            118692 by: Paul Nicholson
            118693 by: Jason Young

    How do you strip Header Info from displaying on your browser?
            118694 by: Phil Powell

    using fopen() to download remote files
            118695 by: Rusty Small

    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:


    anyone know what migth cause this error. I changed the mode to 777, made sure that is was the
    correct owner.group.
    getimagesize: Unable to open 'images/product/i3_berkeley_bed_2drw.jpg' for reading

    =====
    --------------------------------------------------------
    "Theres no such thing as a problem unless the servers are on fire!"

    __________________________________________________
    Do you Yahoo!?
    New DSL Internet Access from SBC & Yahoo!
    http://sbc.yahoo.com

    attached mail follows:


    check the permissions on the directory the image is in as well

    On Wed, 2002-10-02 at 12:51, Dan McCullough wrote:
    > anyone know what migth cause this error. I changed the mode to 777, made sure that is was the
    > correct owner.group.
    > getimagesize: Unable to open 'images/product/i3_berkeley_bed_2drw.jpg' for reading
    >
    > =====
    > --------------------------------------------------------
    > "Theres no such thing as a problem unless the servers are on fire!"
    >
    >
    > __________________________________________________
    > Do you Yahoo!?
    > New DSL Internet Access from SBC & Yahoo!
    > http://sbc.yahoo.com
    >
    > --
    > PHP General Mailing List (http://www.php.net/)
    > To unsubscribe, visit: http://www.php.net/unsub.php
    >
    >
    >

    attached mail follows:


    Don

    I am not a 'PHP guru' and I dont know where you can find an algorithm but:-

    If the only problem is users adding/not using name extensions, then for your
    company exists already test you could remove known extensions from the input
    company name - ltd, plc, etc - and replace this with a wildcard for the
    check.

     eg. SELECT id FROM table WHERE name LIKE '$input_name_without_extensions%'

    Debbie

    ----- Original Message -----
    From: "DonPro" <donprolclcan.com>
    To: "php list" <php-generallists.php.net>
    Sent: Wednesday, October 02, 2002 4:27 PM
    Subject: [PHP] How can I check for variances in spelling within form text
    input fields?

    > Hi,
    >
    > I would like some ideas on how to perform the following. Any input from
    the
    > PHP gurus would be appreciated.
    >
    > I have a form where my customer feels out certain information. Part of
    this
    > information is the company name, address, city and state/province of their
    > customer. I have to assign a unique number to their customer based on the
    > information they typed in.
    >
    > Here is my problem:
    >
    > 1) They may enter the same customer twice but have a slightly different
    > spelling (maybe adding a LTD. to the company name)
    > 2) Two of my customers may have the same customer. They will type it into
    my
    > form but again with variant spelling.
    >
    > I would like to know if there is an algorithm which allows me to check for
    > small variances in spelling so that I would know if this customer has
    > already been assigned my unique number and therefore not assign a
    duplicate
    > number.
    >
    > Thanks,
    > Don
    >
    >
    >
    > --
    > PHP General Mailing List (http://www.php.net/)
    > To unsubscribe, visit: http://www.php.net/unsub.php
    >
    >

    attached mail follows:


    Debbie Dyer wrote:

    >company exists already test you could remove known extensions from the input
    >company name - ltd, plc, etc - and replace this with a wildcard for the
    >check.
    >
    >----- Original Message -----
    >From: "DonPro" <donprolclcan.com>
    >
    >>information is the company name, address, city and state/province of their
    >>customer. I have to assign a unique number to their customer based on the
    >>information they typed in.
    >>
    >>Here is my problem:
    >>
    >>1) They may enter the same customer twice but have a slightly different
    >>spelling (maybe adding a LTD. to the company name)
    >>2) Two of my customers may have the same customer. They will type it into
    >>
    Sorry this post is OT. I think name matching is quite a problem, I've
    never found a foolproof way around it. Debbie's answer is good for the
    question you ask, but still many cases fall through. In the UK, "British
    Telecom" years ago changed its name to "BT" but both get used. "Post
    Office" changed its name to "Consignia" and now back again to "Post
    Office". Then one company buys out another e.g. "Foo Ltd" buys "Bar
    Ltd". I don't think you should go by the name alone.

    Use the post/zip code too. In the UK, a street number (or name) plus the
    postcode is unique to a building (though it does not help with several
    companies/appartments in the same building). The post/zip code matching
    will not help with companies with more than one site.

    HTH
    Chris

    attached mail follows:


    Hi,

    1. you might start by removing things which are common problems... make
    everything lowercase, uppercase, uppercasewords, etc etc (if not permanent,
    just for comparison). You may also strip out leading and trailing
    whitespace, multiple spaces, etc etc. You may choose to remove LTD, PTY,
    GMBH, etc (and all variants) from the string too.

    2. you might want to check out the functions that compare the similarity of
    two strings in a few different ways, for a few different uses. My guess is
    you'll want similar-text() or levenshtein():

    http://www.php.net/manual/en/function.levenshtein.php
    http://www.php.net/manual/en/function.similar-text.php
    http://www.php.net/manual/en/function.soundex.php
    http://www.php.net/manual/en/function.metaphone.php

    Check out the manual's string section, which is where I found all this :)

    Cheers

    Justin

    on 03/10/02 1:27 AM, DonPro (donprolclcan.com) wrote:

    > Hi,
    >
    > I would like some ideas on how to perform the following. Any input from the
    > PHP gurus would be appreciated.
    >
    > I have a form where my customer feels out certain information. Part of this
    > information is the company name, address, city and state/province of their
    > customer. I have to assign a unique number to their customer based on the
    > information they typed in.
    >
    > Here is my problem:
    >
    > 1) They may enter the same customer twice but have a slightly different
    > spelling (maybe adding a LTD. to the company name)
    > 2) Two of my customers may have the same customer. They will type it into my
    > form but again with variant spelling.
    >
    > I would like to know if there is an algorithm which allows me to check for
    > small variances in spelling so that I would know if this customer has
    > already been assigned my unique number and therefore not assign a duplicate
    > number.
    >
    > Thanks,
    > Don
    >
    >

    attached mail follows:


    Assume you've got some class that has one or more classes inherited from it.
    The parent class has a function that is normally called using the ::
    operator (a class function). Assume also that the class function is never
    called from an object function. Is it possible to find if the class
    function was called on the parent class, or on the child class?

    example:
    Class A has a function foo(), callable by A::foo(). Class B extends A. If
    outside code makes the call B::foo(), can you tell from within foo() that
    the function was called on B and not A?

    I think this is impossible but I want to confirm that suspicion. It's
    important that the call B::foo() isn't made from inside any object function,
    so that there's no context for the $this variable; the get_class() function
    isn't applicable.

    attached mail follows:


    I think I know what you mean. You could get it to return the name of the
    class.

    eg.

    class A {
        function foo () {
          return get_class($this);
        }
    }
    class B extends A {
    }
    class C extends A {
    }

      $a = new A();
      $b = new B();
      $c = new C();
      print $a->foo();
      print $b->foo();
      print $c->foo();

    Is this what you mean?

    Debbie

    ----- Original Message -----
    From: "Nick Eby" <nick_ebybonzidev.com>
    To: <php-generallists.php.net>
    Sent: Wednesday, October 02, 2002 6:29 PM
    Subject: [PHP] Inheritance and a class function: on what class was it
    called?

    > Assume you've got some class that has one or more classes inherited from
    it.
    > The parent class has a function that is normally called using the ::
    > operator (a class function). Assume also that the class function is never
    > called from an object function. Is it possible to find if the class
    > function was called on the parent class, or on the child class?
    >
    > example:
    > Class A has a function foo(), callable by A::foo(). Class B extends A. If
    > outside code makes the call B::foo(), can you tell from within foo() that
    > the function was called on B and not A?
    >
    > I think this is impossible but I want to confirm that suspicion. It's
    > important that the call B::foo() isn't made from inside any object
    function,
    > so that there's no context for the $this variable; the get_class()
    function
    > isn't applicable.
    >
    >
    >
    > --
    > PHP General Mailing List (http://www.php.net/)
    > To unsubscribe, visit: http://www.php.net/unsub.php
    >
    >

    attached mail follows:


    not quite... the case I'm interested in is this, given your example:

    print C::foo();

    which would print nothing, unfortunately, since when the function is called
    using the :: operator there is no $this variable. basically what I'm
    looking for is a replacement for get_class($this) when the function is
    called using ::

    thanks

    /nick

    "Debbie Dyer" <debbie.dyerc-u-online.co.uk> wrote in message
    news:054c01c26a3f$34f6d230$de093c3ehomepc...
    > I think I know what you mean. You could get it to return the name of the
    > class.
    >
    > eg.
    >
    > class A {
    > function foo () {
    > return get_class($this);
    > }
    > }
    > class B extends A {
    > }
    > class C extends A {
    > }
    >
    > $a = new A();
    > $b = new B();
    > $c = new C();
    > print $a->foo();
    > print $b->foo();
    > print $c->foo();
    >
    > Is this what you mean?
    >
    > Debbie
    >
    > ----- Original Message -----
    > From: "Nick Eby" <nick_ebybonzidev.com>
    > To: <php-generallists.php.net>
    > Sent: Wednesday, October 02, 2002 6:29 PM
    > Subject: [PHP] Inheritance and a class function: on what class was it
    > called?
    >
    >
    > > Assume you've got some class that has one or more classes inherited from
    > it.
    > > The parent class has a function that is normally called using the ::
    > > operator (a class function). Assume also that the class function is
    never
    > > called from an object function. Is it possible to find if the class
    > > function was called on the parent class, or on the child class?
    > >
    > > example:
    > > Class A has a function foo(), callable by A::foo(). Class B extends A.
    If
    > > outside code makes the call B::foo(), can you tell from within foo()
    that
    > > the function was called on B and not A?
    > >
    > > I think this is impossible but I want to confirm that suspicion. It's
    > > important that the call B::foo() isn't made from inside any object
    > function,
    > > so that there's no context for the $this variable; the get_class()
    > function
    > > isn't applicable.
    > >
    > >
    > >
    > > --
    > > PHP General Mailing List (http://www.php.net/)
    > > To unsubscribe, visit: http://www.php.net/unsub.php
    > >
    > >
    >

    attached mail follows:


    I dont understand what you are saying then or what you are trying to do.

    How can you call C::foo() outside of a class? You access class functions
    externally with ->

    Debbie

    ----- Original Message -----
    From: "Nick Eby" <nick_ebybonzidev.com>
    To: <php-generallists.php.net>
    Sent: Wednesday, October 02, 2002 7:24 PM
    Subject: Re: [PHP] Inheritance and a class function: on what class was it
    called?

    > not quite... the case I'm interested in is this, given your example:
    >
    > print C::foo();
    >
    > which would print nothing, unfortunately, since when the function is
    called
    > using the :: operator there is no $this variable. basically what I'm
    > looking for is a replacement for get_class($this) when the function is
    > called using ::
    >
    > thanks
    >
    > /nick
    >
    > "Debbie Dyer" <debbie.dyerc-u-online.co.uk> wrote in message
    > news:054c01c26a3f$34f6d230$de093c3ehomepc...
    > > I think I know what you mean. You could get it to return the name of the
    > > class.
    > >
    > > eg.
    > >
    > > class A {
    > > function foo () {
    > > return get_class($this);
    > > }
    > > }
    > > class B extends A {
    > > }
    > > class C extends A {
    > > }
    > >
    > > $a = new A();
    > > $b = new B();
    > > $c = new C();
    > > print $a->foo();
    > > print $b->foo();
    > > print $c->foo();
    > >
    > > Is this what you mean?
    > >
    > > Debbie
    > >
    > > ----- Original Message -----
    > > From: "Nick Eby" <nick_ebybonzidev.com>
    > > To: <php-generallists.php.net>
    > > Sent: Wednesday, October 02, 2002 6:29 PM
    > > Subject: [PHP] Inheritance and a class function: on what class was it
    > > called?
    > >
    > >
    > > > Assume you've got some class that has one or more classes inherited
    from
    > > it.
    > > > The parent class has a function that is normally called using the ::
    > > > operator (a class function). Assume also that the class function is
    > never
    > > > called from an object function. Is it possible to find if the class
    > > > function was called on the parent class, or on the child class?
    > > >
    > > > example:
    > > > Class A has a function foo(), callable by A::foo(). Class B extends A.
    > If
    > > > outside code makes the call B::foo(), can you tell from within foo()
    > that
    > > > the function was called on B and not A?
    > > >
    > > > I think this is impossible but I want to confirm that suspicion. It's
    > > > important that the call B::foo() isn't made from inside any object
    > > function,
    > > > so that there's no context for the $this variable; the get_class()
    > > function
    > > > isn't applicable.
    > > >
    > > >
    > > >
    > > > --
    > > > PHP General Mailing List (http://www.php.net/)
    > > > To unsubscribe, visit: http://www.php.net/unsub.php
    > > >
    > > >
    > >
    >
    >
    >
    > --
    > PHP General Mailing List (http://www.php.net/)
    > To unsubscribe, visit: http://www.php.net/unsub.php
    >
    >

    attached mail follows:


    when you call a function with ->, you must call it on an object ($c->foo(),
    for example). the function is termed an "object function" when used that
    way. php has an operator :: that enables that same function to be called
    without a specific object; in this case, I'm referring to it as a "class"
    function. another term for this is usually "static" function. any function
    of a class can be called in both ways. the only catch is that, when called
    as a class function, the function can't in turn call any functions on $this
    or a fatal error will result.

    sorry this is so confusing, I probably should've used the term "static" from
    the beginning.

    /nick

    ----- Original Message -----
    From: "Debbie Dyer" <debbie.dyerc-u-online.co.uk>
    To: "Nick Eby" <nick_ebybonzidev.com>
    Cc: <php-generallists.php.net>
    Sent: Wednesday, October 02, 2002 11:33 AM
    Subject: Re: [PHP] Inheritance and a class function: on what class was it
    called?

    > I dont understand what you are saying then or what you are trying to do.
    >
    > How can you call C::foo() outside of a class? You access class functions
    > externally with ->
    >
    > Debbie
    >
    > ----- Original Message -----
    > From: "Nick Eby" <nick_ebybonzidev.com>
    > To: <php-generallists.php.net>
    > Sent: Wednesday, October 02, 2002 7:24 PM
    > Subject: Re: [PHP] Inheritance and a class function: on what class was it
    > called?
    >
    >
    > > not quite... the case I'm interested in is this, given your example:
    > >
    > > print C::foo();
    > >
    > > which would print nothing, unfortunately, since when the function is
    > called
    > > using the :: operator there is no $this variable. basically what I'm
    > > looking for is a replacement for get_class($this) when the function is
    > > called using ::
    > >
    > > thanks
    > >
    > > /nick
    > >
    > > "Debbie Dyer" <debbie.dyerc-u-online.co.uk> wrote in message
    > > news:054c01c26a3f$34f6d230$de093c3ehomepc...
    > > > I think I know what you mean. You could get it to return the name of
    the
    > > > class.
    > > >
    > > > eg.
    > > >
    > > > class A {
    > > > function foo () {
    > > > return get_class($this);
    > > > }
    > > > }
    > > > class B extends A {
    > > > }
    > > > class C extends A {
    > > > }
    > > >
    > > > $a = new A();
    > > > $b = new B();
    > > > $c = new C();
    > > > print $a->foo();
    > > > print $b->foo();
    > > > print $c->foo();
    > > >
    > > > Is this what you mean?
    > > >
    > > > Debbie
    > > >
    > > > ----- Original Message -----
    > > > From: "Nick Eby" <nick_ebybonzidev.com>
    > > > To: <php-generallists.php.net>
    > > > Sent: Wednesday, October 02, 2002 6:29 PM
    > > > Subject: [PHP] Inheritance and a class function: on what class was it
    > > > called?
    > > >
    > > >
    > > > > Assume you've got some class that has one or more classes inherited
    > from
    > > > it.
    > > > > The parent class has a function that is normally called using the ::
    > > > > operator (a class function). Assume also that the class function is
    > > never
    > > > > called from an object function. Is it possible to find if the class
    > > > > function was called on the parent class, or on the child class?
    > > > >
    > > > > example:
    > > > > Class A has a function foo(), callable by A::foo(). Class B extends
    A.
    > > If
    > > > > outside code makes the call B::foo(), can you tell from within foo()
    > > that
    > > > > the function was called on B and not A?
    > > > >
    > > > > I think this is impossible but I want to confirm that suspicion.
    It's
    > > > > important that the call B::foo() isn't made from inside any object
    > > > function,
    > > > > so that there's no context for the $this variable; the get_class()
    > > > function
    > > > > isn't applicable.
    > > > >
    > > > >
    > > > >
    > > > > --
    > > > > PHP General Mailing List (http://www.php.net/)
    > > > > To unsubscribe, visit: http://www.php.net/unsub.php
    > > > >
    > > > >
    > > >
    > >
    > >
    > >
    > > --
    > > PHP General Mailing List (http://www.php.net/)
    > > To unsubscribe, visit: http://www.php.net/unsub.php
    > >
    > >

    attached mail follows:


    "I probably should've used the term "static" from the beginning." <- maybe

    The mistake is mine not yours. I know about the :: operator I use it all the
    time (but within classes parent::function() etc) - but I never realised
    until now that PHP will let you use any class before instantiation (and
    nearly all my PHP work uses classes). I have never even attempted to try it
    because in all other languages I know trying to use an ordinary class before
    instantiation will just result in a null pointer error or the equivalent of
    one.

    PHP OOP is different I know, one big example is that there is no provision
    for data encapsulation - one of the main objectives of OOP, neither can you
    differentiate between types of classes/methods (which is probably what is
    causing the confusion).

    Now it seems it is even more different than I thought. All I can say is
    mmhh.......

    Debbie

    ----- Original Message -----
    From: "Nick Eby" <nick_ebybonzidev.com>
    To: "Debbie Dyer" <debbie.dyerc-u-online.co.uk>
    Cc: <php-generallists.php.net>
    Sent: Wednesday, October 02, 2002 7:53 PM
    Subject: Re: [PHP] Inheritance and a class function: on what class was it
    called?

    > when you call a function with ->, you must call it on an object
    ($c->foo(),
    > for example). the function is termed an "object function" when used that
    > way. php has an operator :: that enables that same function to be called
    > without a specific object; in this case, I'm referring to it as a "class"
    > function. another term for this is usually "static" function. any
    function
    > of a class can be called in both ways. the only catch is that, when
    called
    > as a class function, the function can't in turn call any functions on
    $this
    > or a fatal error will result.
    >
    > sorry this is so confusing, I probably should've used the term "static"
    from
    > the beginning.
    >
    > /nick
    >
    > ----- Original Message -----
    > From: "Debbie Dyer" <debbie.dyerc-u-online.co.uk>
    > To: "Nick Eby" <nick_ebybonzidev.com>
    > Cc: <php-generallists.php.net>
    > Sent: Wednesday, October 02, 2002 11:33 AM
    > Subject: Re: [PHP] Inheritance and a class function: on what class was it
    > called?
    >
    >
    > > I dont understand what you are saying then or what you are trying to do.
    > >
    > > How can you call C::foo() outside of a class? You access class functions
    > > externally with ->
    > >
    > > Debbie
    > >
    > > ----- Original Message -----
    > > From: "Nick Eby" <nick_ebybonzidev.com>
    > > To: <php-generallists.php.net>
    > > Sent: Wednesday, October 02, 2002 7:24 PM
    > > Subject: Re: [PHP] Inheritance and a class function: on what class was
    it
    > > called?
    > >
    > >
    > > > not quite... the case I'm interested in is this, given your example:
    > > >
    > > > print C::foo();
    > > >
    > > > which would print nothing, unfortunately, since when the function is
    > > called
    > > > using the :: operator there is no $this variable. basically what I'm
    > > > looking for is a replacement for get_class($this) when the function is
    > > > called using ::
    > > >
    > > > thanks
    > > >
    > > > /nick
    > > >
    > > > "Debbie Dyer" <debbie.dyerc-u-online.co.uk> wrote in message
    > > > news:054c01c26a3f$34f6d230$de093c3ehomepc...
    > > > > I think I know what you mean. You could get it to return the name of
    > the
    > > > > class.
    > > > >
    > > > > eg.
    > > > >
    > > > > class A {
    > > > > function foo () {
    > > > > return get_class($this);
    > > > > }
    > > > > }
    > > > > class B extends A {
    > > > > }
    > > > > class C extends A {
    > > > > }
    > > > >
    > > > > $a = new A();
    > > > > $b = new B();
    > > > > $c = new C();
    > > > > print $a->foo();
    > > > > print $b->foo();
    > > > > print $c->foo();
    > > > >
    > > > > Is this what you mean?
    > > > >
    > > > > Debbie
    > > > >
    > > > > ----- Original Message -----
    > > > > From: "Nick Eby" <nick_ebybonzidev.com>
    > > > > To: <php-generallists.php.net>
    > > > > Sent: Wednesday, October 02, 2002 6:29 PM
    > > > > Subject: [PHP] Inheritance and a class function: on what class was
    it
    > > > > called?
    > > > >
    > > > >
    > > > > > Assume you've got some class that has one or more classes
    inherited
    > > from
    > > > > it.
    > > > > > The parent class has a function that is normally called using the
    ::
    > > > > > operator (a class function). Assume also that the class function
    is
    > > > never
    > > > > > called from an object function. Is it possible to find if the
    class
    > > > > > function was called on the parent class, or on the child class?
    > > > > >
    > > > > > example:
    > > > > > Class A has a function foo(), callable by A::foo(). Class B
    extends
    > A.
    > > > If
    > > > > > outside code makes the call B::foo(), can you tell from within
    foo()
    > > > that
    > > > > > the function was called on B and not A?
    > > > > >
    > > > > > I think this is impossible but I want to confirm that suspicion.
    > It's
    > > > > > important that the call B::foo() isn't made from inside any object
    > > > > function,
    > > > > > so that there's no context for the $this variable; the get_class()
    > > > > function
    > > > > > isn't applicable.
    > > > > >
    > > > > >
    > > > > >
    > > > > > --
    > > > > > PHP General Mailing List (http://www.php.net/)
    > > > > > To unsubscribe, visit: http://www.php.net/unsub.php
    > > > > >
    > > > > >
    > > > >
    > > >
    > > >
    > > >
    > > > --
    > > > PHP General Mailing List (http://www.php.net/)
    > > > To unsubscribe, visit: http://www.php.net/unsub.php
    > > >
    > > >
    >
    >
    > --
    > PHP General Mailing List (http://www.php.net/)
    > To unsubscribe, visit: http://www.php.net/unsub.php
    >
    >

    attached mail follows:


    > The mistake is mine not yours. I know about the :: operator I use it all the
    > time (but within classes parent::function() etc) - but I never realised
    > until now that PHP will let you use any class before instantiation (and
    > nearly all my PHP work uses classes). I have never even attempted to try it
    > because in all other languages I know trying to use an ordinary class before
    > instantiation will just result in a null pointer error or the equivalent of
    > one.
    >
    > PHP OOP is different I know, one big example is that there is no provision
    > for data encapsulation - one of the main objectives of OOP, neither can you
    > differentiate between types of classes/methods (which is probably what is
    > causing the confusion).
    >
    > Now it seems it is even more different than I thought. All I can say is
    > mmhh.......

    Most OO languages allow static method calls. C++, Java, Python, Ruby,
    etc. PHP may have some OO differences, but this is not one of them.

    -Rasmus

    attached mail follows:


    PHP allows static method calls... But back to my original question...
    inside a method that has been called statically, can I determine for what
    class the method was called? Again, obviously the question is only
    applicable if there is some inheritance involved, and the child class does
    not declare the method in question. Below is my original example spelled
    out in code... the call to get_class is not valid since there won't be a
    $this variable in the context of the static method... Can I replace it with
    something that will cause it to echo "B"?

    Class A {
    function staticFunc() { echo get_class($this); }
    }

    Class B extends A {}

    B::staticFunc();

    thanks again
    /nick

    ----- Original Message -----
    From: "Rasmus Lerdorf" <rasmusphp.net>
    To: "Debbie Dyer" <debbie.dyerc-u-online.co.uk>
    Cc: "Nick Eby" <nick_ebybonzidev.com>; <php-generallists.php.net>
    Sent: Wednesday, October 02, 2002 3:08 PM
    Subject: Re: [PHP] Inheritance and a class function: on what class was it
    called?

    > > The mistake is mine not yours. I know about the :: operator I use it all
    the
    > > time (but within classes parent::function() etc) - but I never realised
    > > until now that PHP will let you use any class before instantiation (and
    > > nearly all my PHP work uses classes). I have never even attempted to try
    it
    > > because in all other languages I know trying to use an ordinary class
    before
    > > instantiation will just result in a null pointer error or the equivalent
    of
    > > one.
    > >
    > > PHP OOP is different I know, one big example is that there is no
    provision
    > > for data encapsulation - one of the main objectives of OOP, neither can
    you
    > > differentiate between types of classes/methods (which is probably what
    is
    > > causing the confusion).
    > >
    > > Now it seems it is even more different than I thought. All I can say is
    > > mmhh.......
    >
    > Most OO languages allow static method calls. C++, Java, Python, Ruby,
    > etc. PHP may have some OO differences, but this is not one of them.
    >
    > -Rasmus

    attached mail follows:


    Since static method calls are completely disconnected from any class
    instance asking which class the method call is from is rather meaningless,
    and no, I don't think there is any way to get that.

    -Rasmus

    On Wed, 2 Oct 2002, Nick Eby wrote:

    > PHP allows static method calls... But back to my original question...
    > inside a method that has been called statically, can I determine for what
    > class the method was called? Again, obviously the question is only
    > applicable if there is some inheritance involved, and the child class does
    > not declare the method in question. Below is my original example spelled
    > out in code... the call to get_class is not valid since there won't be a
    > $this variable in the context of the static method... Can I replace it with
    > something that will cause it to echo "B"?
    >
    > Class A {
    > function staticFunc() { echo get_class($this); }
    > }
    >
    > Class B extends A {}
    >
    > B::staticFunc();
    >
    > thanks again
    > /nick
    >
    > ----- Original Message -----
    > From: "Rasmus Lerdorf" <rasmusphp.net>
    > To: "Debbie Dyer" <debbie.dyerc-u-online.co.uk>
    > Cc: "Nick Eby" <nick_ebybonzidev.com>; <php-generallists.php.net>
    > Sent: Wednesday, October 02, 2002 3:08 PM
    > Subject: Re: [PHP] Inheritance and a class function: on what class was it
    > called?
    >
    >
    > > > The mistake is mine not yours. I know about the :: operator I use it all
    > the
    > > > time (but within classes parent::function() etc) - but I never realised
    > > > until now that PHP will let you use any class before instantiation (and
    > > > nearly all my PHP work uses classes). I have never even attempted to try
    > it
    > > > because in all other languages I know trying to use an ordinary class
    > before
    > > > instantiation will just result in a null pointer error or the equivalent
    > of
    > > > one.
    > > >
    > > > PHP OOP is different I know, one big example is that there is no
    > provision
    > > > for data encapsulation - one of the main objectives of OOP, neither can
    > you
    > > > differentiate between types of classes/methods (which is probably what
    > is
    > > > causing the confusion).
    > > >
    > > > Now it seems it is even more different than I thought. All I can say is
    > > > mmhh.......
    > >
    > > Most OO languages allow static method calls. C++, Java, Python, Ruby,
    > > etc. PHP may have some OO differences, but this is not one of them.
    > >
    > > -Rasmus
    >

    attached mail follows:


    Without them being defined in some special way?

    I am very surprised that after 7 years of OOP I dont know that but I will
    check it out tomorrow.

    Debbie

    ----- Original Message -----
    From: "Rasmus Lerdorf" <rasmusphp.net>
    To: "Nick Eby" <nick_ebybonzidev.com>
    Cc: "Debbie Dyer" <debbie.dyerc-u-online.co.uk>;
    <php-generallists.php.net>
    Sent: Wednesday, October 02, 2002 11:28 PM
    Subject: Re: [PHP] Inheritance and a class function: on what class was it
    called?

    > Since static method calls are completely disconnected from any class
    > instance asking which class the method call is from is rather meaningless,
    > and no, I don't think there is any way to get that.
    >
    > -Rasmus
    >
    > On Wed, 2 Oct 2002, Nick Eby wrote:
    >
    > > PHP allows static method calls... But back to my original question...
    > > inside a method that has been called statically, can I determine for
    what
    > > class the method was called? Again, obviously the question is only
    > > applicable if there is some inheritance involved, and the child class
    does
    > > not declare the method in question. Below is my original example
    spelled
    > > out in code... the call to get_class is not valid since there won't be a
    > > $this variable in the context of the static method... Can I replace it
    with
    > > something that will cause it to echo "B"?
    > >
    > > Class A {
    > > function staticFunc() { echo get_class($this); }
    > > }
    > >
    > > Class B extends A {}
    > >
    > > B::staticFunc();
    > >
    > > thanks again
    > > /nick
    > >
    > > ----- Original Message -----
    > > From: "Rasmus Lerdorf" <rasmusphp.net>
    > > To: "Debbie Dyer" <debbie.dyerc-u-online.co.uk>
    > > Cc: "Nick Eby" <nick_ebybonzidev.com>; <php-generallists.php.net>
    > > Sent: Wednesday, October 02, 2002 3:08 PM
    > > Subject: Re: [PHP] Inheritance and a class function: on what class was
    it
    > > called?
    > >
    > >
    > > > > The mistake is mine not yours. I know about the :: operator I use it
    all
    > > the
    > > > > time (but within classes parent::function() etc) - but I never
    realised
    > > > > until now that PHP will let you use any class before instantiation
    (and
    > > > > nearly all my PHP work uses classes). I have never even attempted to
    try
    > > it
    > > > > because in all other languages I know trying to use an ordinary
    class
    > > before
    > > > > instantiation will just result in a null pointer error or the
    equivalent
    > > of
    > > > > one.
    > > > >
    > > > > PHP OOP is different I know, one big example is that there is no
    > > provision
    > > > > for data encapsulation - one of the main objectives of OOP, neither
    can
    > > you
    > > > > differentiate between types of classes/methods (which is probably
    what
    > > is
    > > > > causing the confusion).
    > > > >
    > > > > Now it seems it is even more different than I thought. All I can say
    is
    > > > > mmhh.......
    > > >
    > > > Most OO languages allow static method calls. C++, Java, Python, Ruby,
    > > > etc. PHP may have some OO differences, but this is not one of them.
    > > >
    > > > -Rasmus
    > >
    >
    >

    attached mail follows:


    which is what I suspected... thanks for confirming. and yes, the call is
    disconnected from any class _instance_, but not from any class. as you said
    before, PHP has some OO differences from java, etc, and this is one of
    them... if you had static members, then methods called statically would have
    to know on what class they were called. anyway thanks again

    /nick

    ----- Original Message -----
    From: "Rasmus Lerdorf" <rasmusphp.net>
    To: "Nick Eby" <nick_ebybonzidev.com>
    Cc: "Debbie Dyer" <debbie.dyerc-u-online.co.uk>;
    <php-generallists.php.net>
    Sent: Wednesday, October 02, 2002 3:28 PM
    Subject: Re: [PHP] Inheritance and a class function: on what class was it
    called?

    > Since static method calls are completely disconnected from any class
    > instance asking which class the method call is from is rather meaningless,
    > and no, I don't think there is any way to get that.
    >
    > -Rasmus
    >
    > On Wed, 2 Oct 2002, Nick Eby wrote:
    >
    > > PHP allows static method calls... But back to my original question...
    > > inside a method that has been called statically, can I determine for
    what
    > > class the method was called? Again, obviously the question is only
    > > applicable if there is some inheritance involved, and the child class
    does
    > > not declare the method in question. Below is my original example
    spelled
    > > out in code... the call to get_class is not valid since there won't be a
    > > $this variable in the context of the static method... Can I replace it
    with
    > > something that will cause it to echo "B"?
    > >
    > > Class A {
    > > function staticFunc() { echo get_class($this); }
    > > }
    > >
    > > Class B extends A {}
    > >
    > > B::staticFunc();
    > >
    > > thanks again
    > > /nick
    > >

    attached mail follows:


    Webmaster MBTRADINGCO wrote:

    >I'm sure there has to be a way to verify which IP address is accessing
    >
    Don't count on it to identify users on the internet though.

    Regards

    Chris

    attached mail follows:


    Actually I'm just using it so a customer can acces a PWS that is
    broadcasting on its own security cameras. I have a DSL that disconnects
    every 8 hours, and gives dinamyc IP, so each time it connects it goes to
    my site, and writes down the addres, so my customer can access the
    report, and see what is the current IP address for it's server.

    Thanks to all it worked.

    -----Mensaje original-----
    De: Jon Haworth [mailto:jhaworthwitanjardine.co.uk]
    Enviado el: Miércoles, 02 de Octubre de 2002 10:19 a.m.
    Para: php-generallists.php.net
    Asunto: RE: [PHP] Getting users IP address into a variable.

    Hi,

    > > I'm sure there has to be a way to verify which IP
    > > address is accessing from.
    > > $ip=HTP_GET_????
    >
    > $REMOTE_ADDR

    ...and to deal with some (but not all) proxies:

    $ip = (getenv("HTTP_X_FORWARDED_FOR"))
        ? getenv("HTTP_X_FORWARDED_FOR")
        : getenv("REMOTE_ADDR");

    Either way you're still going to get stuff that isn't right, so make
    sure
    (a) you validate the contents of $ip before doing anything with it, and
    (b)
    you're not using it for anything critical.

    Cheers
    Jon

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

    attached mail follows:


    For a coursework assignment I have to investigate this thing where you do the following for example:

    264 - Choose 3 digits that are not the same 12 - Find the sum of them.

    264 246 624 642 426 462 - List all the possible combinations of those digits _____ 2664 - Add the combinations

    2664 / 12 = 222 - Divide the answer by the sum of the three digits and you allways get 222! To speed up the process of finding any exceptions if any, I thought id use php to do this, however i get a problem, the script runs without any coding errors, but it doesnt do what i want it to do - instead of returning any three digit combo that doesnt return 222, it just prints EVERY combo whice passes my conditional statement to weed out numbers that have digits where 2 or more are the same.

    Here is my code:

    <?php

    for ($i = 012; $i < 987; $i ++) {

    $comma = chunk_split($i, 1, ","); $split = explode(",", $comma);

    if ($split[0] == $split[1] || $split[0] == $split[2] || $split[1] == $split[2]) { } else{

    $digitstotal = $split[0] + $split[1] + $split[2];

    $num1 = "$split[0].$split[1].$split[2]"; $num2 = "$split[0].$split[2].$split[1]"; $num3 = "$split[1].$split[0].$split[2]"; $num4 = "$split[1].$split[2].$split[0]"; $num5 = "$split[2].$split[0].$split[1]"; $num6 = "$split[2].$split[1].$split[0]";

    $numtotal = $num1 + $num2 + $num3 + $num4 + $num5 + $num6;

    $answer = $numtotal / $digitstotal;

    if ($answer != 222) { echo("$i does not return 222!<br>"); } } } ?>

    What is wrong with it? Any help at all is greatly apreciated.

    attached mail follows:


    Well, since it's for school I'll only point out a couple of issues...

    - your for loop will never test the number 987 even though it should.

    - add the following line rightr after you compute $numtotal:

    print("$numtotal = $num1 + $num2 + $num3 + $num4 + $num5 + $num6\n");

    and you'll see that you'll get output like:

    28.6 = 2.6.5 + 2.5.6 + 6.2.5 + 6.5.2 + 5.2.6 + 5.6.2

    which should help you understand why it's not doing what you think it's doing.

    good luck.

    On Wed, 2 Oct 2002 tonytabzilla.com wrote:

    > For a coursework assignment I have to investigate this thing where you do > the following for example: > > 264 - Choose 3 digits that are not the same > 12 - Find the sum of them. > > 264 > 246 > 624 > 642 > 426 > 462 - List all the possible combinations of those digits > _____ > 2664 - Add the combinations > > 2664 / 12 = 222 - Divide the answer by the sum of the three digits > and you allways get 222! > To speed up the process of finding any exceptions if any, I thought id use > php to do this, however i get a problem, the script runs without any coding > errors, but it doesnt do what i want it to do - instead of returning any > three digit combo that doesnt return 222, it just prints EVERY combo whice > passes my conditional statement to weed out numbers that have digits where 2 > or more are the same. > > Here is my code: > > <?php > > for ($i = 012; $i < 987; $i ++) { > > $comma = chunk_split($i, 1, ","); > $split = explode(",", $comma); > > if ($split[0] == $split[1] || $split[0] == $split[2] || $split[1] == > $split[2]) { > } else{ > > $digitstotal = $split[0] + $split[1] + $split[2]; > > $num1 = "$split[0].$split[1].$split[2]"; > $num2 = "$split[0].$split[2].$split[1]"; > $num3 = "$split[1].$split[0].$split[2]"; > $num4 = "$split[1].$split[2].$split[0]"; > $num5 = "$split[2].$split[0].$split[1]"; > $num6 = "$split[2].$split[1].$split[0]"; > > $numtotal = $num1 + $num2 + $num3 + $num4 + $num5 + $num6; > > $answer = $numtotal / $digitstotal; > > if ($answer != 222) { > echo("$i does not return 222!<br>"); > } > } > } > ?> > > What is wrong with it? Any help at all is greatly apreciated. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

    attached mail follows:


    > What is wrong with it? Any help at all is greatly apreciated.

    Consider the differences between my code below and yours. And as far as I can see, there's no combination higher than eleven, lower than 987 which doesn't work out.

    <? for ($i = 12; $i < 987; $i++) {

    $newI = $i;

    settype($newI, "string");

    $newI = str_pad($newI, 3, "0", STR_PAD_LEFT);

    $digits = $newI[0] + $newI[1] + $newI[2];

    $num1 = $newI[0].$newI[1].$newI[2]; $num2 = $newI[0].$newI[2].$newI[1]; $num3 = $newI[1].$newI[0].$newI[2]; $num4 = $newI[1].$newI[2].$newI[0]; $num5 = $newI[2].$newI[0].$newI[1]; $num6 = $newI[2].$newI[1].$newI[0];

    $sum = $num1 + $num2 + $num3 + $num4 + $num5 + $num6;

    $answer = $sum / $digits;

    if ($answer != "222") { echo $i." does not fit in the scheme."; }

    } ?>

    Jome

    attached mail follows:


    tonytabzilla.com wrote:

    >errors, but it doesnt do what i want it to do - instead of returning any >three digit combo that doesnt return 222, it just prints EVERY combo whice >passes my conditional statement to weed out numbers that have digits where 2 >or more are the same. > I can't write bug-free code first time either. I have had to learn to debug. In this case I would start just before your line...

    >if ($answer != 222) { > ...and put in "echo $answer" to see what number it actually has.

    HTH Chris

    attached mail follows:


    Hi,

    I am trying to upgrade my script which currently uses globals (and register_globals=on) to turning that flag off. The online documentation on register globas has the following code recommended by users in order to register the variables:

    $GLOBALS["dbname"] = "dbname";

    //register globals foreach ($GLOBALS as $key=>$val) { if ($key !="GLOBALS') { eval("\$$key = '$val';"); } }

    I am using the global array to connect to my database. I find that if I insert the code above, I get an error message that the document contains no data. Can anyone tell me why? Perhaps I would be better off just declaring the variable? Would that take care of the problem?

    $dbname= "dbname";

    Thanks,

    Nicole

    -- 
    ########################
    Nicole Lallande
    nicolenmlconsulting.com
    760.753.6766
    ########################
    

    attached mail follows:


    Hey folks,

    Whenever I try to open files via fopen i get the following message

    stat failed for Resource for id #1

    Fopen Wrapper is turned on in php.ini

    What wrong?

    attached mail follows:


    Hello everyone!

    On Win 2k, what is PHP's user name? Or, what username does PHP access files (on the system) as?

    -john

    =P e p i e D e s i g n s www.pepiedesigns.com Providing Solutions That Increase Productivity

    Web Developement. Database. Hosting. Multimedia.

    attached mail follows:


    The one that accesses the filesystem through PHP is the webserver itself, not PHP. And as your server is probably instaleld as a service, it runs under SYSTEM credentials.

    ----- Original Message ----- From: "[-^-!-%-" <monfortengineering.sdsu.edu> To: <php-generallists.php.net> Sent: Wednesday, October 02, 2002 9:43 PM Subject: [PHP] PHP User Name on Win2000

    > > Hello everyone! > > On Win 2k, what is PHP's user name? Or, what username does PHP access > files (on the system) as? > > -john > > =P e p i e D e s i g n s > www.pepiedesigns.com > Providing Solutions That Increase Productivity > > Web Developement. Database. Hosting. Multimedia. > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

    attached mail follows:


    If you are using IIS, then PHP runs as the IIS user, IUSR_<computer_name>. If your computer name is Mango, then it'd be IUSR_MANGO.

    ---John Holmes...

    > -----Original Message----- > From: Ionut Ciocirlan [mailto:ionut.ciocirlanlykon.ro] > Sent: Wednesday, October 02, 2002 2:54 PM > To: PHP List > Subject: Re: [PHP] PHP User Name on Win2000 > > The one that accesses the filesystem through PHP is the webserver itself, > not PHP. And as your server is probably instaleld as a service, it runs > under SYSTEM credentials. > > ----- Original Message ----- > From: "[-^-!-%-" <monfortengineering.sdsu.edu> > To: <php-generallists.php.net> > Sent: Wednesday, October 02, 2002 9:43 PM > Subject: [PHP] PHP User Name on Win2000 > > > > > > Hello everyone! > > > > On Win 2k, what is PHP's user name? Or, what username does PHP access > > files (on the system) as? > > > > -john > > > > =P e p i e D e s i g n s > > www.pepiedesigns.com > > Providing Solutions That Increase Productivity > > > > Web Developement. Database. Hosting. Multimedia. > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

    attached mail follows:


    Folks,

    I want to keep track of referers to my site. I want to store the domain name of the referer in a db field. I want 'just' the domain name, not the full url.

    So I need a snippet of code that could parse the $HTTP_REFERER, and return just the domain name.

    Example....

    1) http://www.google.com 2) http://www.google.com/ 3) http://www.google.com/search?sourceid=navclient&q=evil+microsoft

    ... would all give me http://www.google.com

    Could anyone give me a hand? Thanks!

    -- 
    : Joseph Szobody :
    "Computers are like airconditioners: They stop working properly if you open windows."
    

    attached mail follows:


    Never mind. Didn't realize PHP had the parse_url function. Got it!

    attached mail follows:


    I think parseurl() does what you want... it's in the manual (surprise surprise!!)

    http://php.net/parseurl

    Justin

    on 03/10/02 5:18 AM, Joseph Szobody (jszobodyexcite.com) wrote:

    > Folks, > > I want to keep track of referers to my site. I want to store the domain name > of the referer in a db field. I want 'just' the domain name, not the full url. > > So I need a snippet of code that could parse the $HTTP_REFERER, and return > just the domain name. > > Example.... > > 1) http://www.google.com > 2) http://www.google.com/ > 3) http://www.google.com/search?sourceid=navclient&q=evil+microsoft > > ... would all give me http://www.google.com > > Could anyone give me a hand? Thanks!

    attached mail follows:


    I have the following line in a program I'm working on:

    $query = "UPDATE countertable SET CurrDate = '$ndate' WHERE ID = $id"

    $ndate is a properly formated date read from a text field on a form on the previous page. When I run the query using mysql_query, it returns TRUE each time, but the field is not updated. The only explanation I can think of is that there is something wrong with the date value. I've echoed it to the screen and it looks fine, but the query still doesn't work. Any suggestions?

    Thanks in advance,

    Brad

    attached mail follows:


    > From: Brad Harriger [mailto:bradharrigerclarionhospital.org] > Sent: Wednesday, October 02, 2002 3:17 PM > Subject: [PHP] Setting date fields in mysql queries > > > I have the following line in a program I'm working on: > > $query = "UPDATE countertable SET CurrDate = '$ndate' WHERE ID = $id" > > $ndate is a properly formated date read from a text field on > a form on > the previous page. When I run the query using mysql_query, > it returns > TRUE each time, but the field is not updated. The only explanation I > can think of is that there is something wrong with the date > value. I've > echoed it to the screen and it looks fine, but the query > still doesn't > work. Any suggestions?

    When you say it looks fine, are you meaning it looks like 2002-10-02?

    attached mail follows:


    [snip] I have the following line in a program I'm working on:

    $query = "UPDATE countertable SET CurrDate = '$ndate' WHERE ID = $id"

    $ndate is a properly formated date read from a text field on a form on the previous page. When I run the query using mysql_query, it returns TRUE each time, but the field is not updated. The only explanation I can think of is that there is something wrong with the date value. I've echoed it to the screen and it looks fine, but the query still doesn't work. Any suggestions? [/snip]

    Are you actually running the query somehow? Like with mysql_query()? Since you didn't deliver more code it this is the guess I would take.

    $query = "UPDATE countertable SET CurrDate = '$ndate' WHERE ID = $id" ; // do some error checking if(!($data = mysql_query($query, $your_bd_connection))){ print("MySQL reports: " . mysql_error() . "\n"); exit(); }

    HTH!

    Jay

    attached mail follows:


    Hi,

    it's a great tip to install PhpMyAdmin - or phpPgAdmin for PostgresSQL - this will only take you at most half an hour even for a newcomer.

    You can then easily test queries, see any error messages and see what result they have on tables.

    In this case I'd echo out the query

    echo $query = "UPDATE countertable SET CurrDate = '$ndate' WHERE ID = $id"

    and try to cut-and-paste it into the query-field in PhpMyAdmin.

    When you say "nothing happens" you'd probably discover that ID is a number not matching anything _or_ that $nDate and the field are not proper date values ;-)

    Hope it helps!

    Frank, U5

    ~~~~ PHP work!

    Looking for PHP work over the net? Or would like to try to work in South East Asia's most exiting place, Bangkok? Then jump to http://www.u5.com/ and fill out the Developers Form. We are urgently looking for new people in October 2002 ~~~~

    At 15:16 2/10/2002 -0400, you wrote: >I have the following line in a program I'm working on: > >$query = "UPDATE countertable SET CurrDate = '$ndate' WHERE ID = $id" > >$ndate is a properly formated date read from a text field on a form on the >previous page. When I run the query using mysql_query, it returns TRUE >each time, but the field is not updated. The only explanation I can think >of is that there is something wrong with the date value. I've echoed it >to the screen and it looks fine, but the query still doesn't work. Any >suggestions? > >Thanks in advance, > >Brad > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php

    attached mail follows:


    I keep receiving the following error when I try to use fopen() to a remote server, regardless of which server I try to connect to apparently. I've verified that allow_url_fopen is set to true, so this should be functioning properly. I'm only trying to read the contents of the file so why doesn't this act like a web browser would?

    I can browse to the location with my web browser, but I cannot get the contents of the file with PHP. Why is this happening to me? The error is "bad file descriptor"

    attached mail follows:


    I am looking for a way to find the highest 5 and lowest 5 numbers within 300 or so numbers. Here is what I have so far...

    $Tickers = array(); $Current = array();

    // SQL QUERY TO GET TICKERS MSSQL_CONNECT($HostName,$UserName,$Password); mssql_select_db($DBName) or DIE("Table unavailable");

    $Results = MSSQL_QUERY("SELECT CompanyName,Ticker FROM Company WHERE Ticker != ''");

    $RowCount = MSSQL_NUM_ROWS($Results); print "$RowCount Number of Tickers<br>\n";

    if($RowCount != 0) { for ($i = 0; $Field = MSSQL_FETCH_ARRAY($Results); ++$i) { array_push($Tickers, $Field["Ticker"]); } } else { print "There was nothing selected in the Query, it may have been bad."; }

    foreach($Tickers as $Ticker) { Get Last price on the ticker from database. and... array_push($Current, $Value); }

    Now that I have the values in an array I would like to pull out the five highest and the 5 lowest. Is there a way to do that....if not, is there another way to do what I am looking for. I keep thinking I would have to compare each ticker against all the others to verify it's standing...and that seems like a lot of work.

    attached mail follows:


    Sort the arrays and pick off the first and last elements.

    On Wed, 2 Oct 2002, Christopher J. Crane wrote:

    > I am looking for a way to find the highest 5 and lowest 5 numbers within 300 > or so numbers. Here is what I have so far... > > $Tickers = array(); > $Current = array(); > > > // SQL QUERY TO GET TICKERS > MSSQL_CONNECT($HostName,$UserName,$Password); > mssql_select_db($DBName) or DIE("Table unavailable"); > > $Results = MSSQL_QUERY("SELECT CompanyName,Ticker FROM Company WHERE > Ticker != ''"); > > $RowCount = MSSQL_NUM_ROWS($Results); > print "$RowCount Number of Tickers<br>\n"; > > if($RowCount != 0) { > for ($i = 0; $Field = MSSQL_FETCH_ARRAY($Results); ++$i) { > array_push($Tickers, $Field["Ticker"]); } > } > else { print "There was nothing selected in the Query, it may have been > bad."; } > > > foreach($Tickers as $Ticker) { Get Last price on the ticker from database. > and... array_push($Current, $Value); } > > Now that I have the values in an array I would like to pull out the five > highest and the 5 lowest. Is there a way to do that....if not, is there > another way to do what I am looking for. I keep thinking I would have to > compare each ticker against all the others to verify it's standing...and > that seems like a lot of work. > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

    attached mail follows:


    Thank you very much, I did not know sort would work this way. Makes complete sense now though. Thansk again I will give it a shot. "Rasmus Lerdorf" <rasmusphp.net> wrote in message news:Pine.LNX.4.44.0210021248210.27901-100000www.lerdorf.com... > Sort the arrays and pick off the first and last elements. > > On Wed, 2 Oct 2002, Christopher J. Crane wrote: > > > I am looking for a way to find the highest 5 and lowest 5 numbers within 300 > > or so numbers. Here is what I have so far... > > > > $Tickers = array(); > > $Current = array(); > > > > > > // SQL QUERY TO GET TICKERS > > MSSQL_CONNECT($HostName,$UserName,$Password); > > mssql_select_db($DBName) or DIE("Table unavailable"); > > > > $Results = MSSQL_QUERY("SELECT CompanyName,Ticker FROM Company WHERE > > Ticker != ''"); > > > > $RowCount = MSSQL_NUM_ROWS($Results); > > print "$RowCount Number of Tickers<br>\n"; > > > > if($RowCount != 0) { > > for ($i = 0; $Field = MSSQL_FETCH_ARRAY($Results); ++$i) { > > array_push($Tickers, $Field["Ticker"]); } > > } > > else { print "There was nothing selected in the Query, it may have been > > bad."; } > > > > > > foreach($Tickers as $Ticker) { Get Last price on the ticker from database. > > and... array_push($Current, $Value); } > > > > Now that I have the values in an array I would like to pull out the five > > highest and the 5 lowest. Is there a way to do that....if not, is there > > another way to do what I am looking for. I keep thinking I would have to > > compare each ticker against all the others to verify it's standing...and > > that seems like a lot of work. > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > >

    attached mail follows:


    Hi people,

    i've been searching for a while in google and vivisimo for docs that treats paging techniques for php and mysql. And so far i seek nothing. I always get stuck with empty documents (if you know what I mean).

    Can U give me a hand with this. If you already have a doc of this nature, or the URL to get one ?

    Regards, and thanks in advance...

    Francisco M. Vaucher

    attached mail follows:


    Just pass the current position from one page to the next and use a "LIMIT start,num" clause.

    -Rasmus

    On Wed, 2 Oct 2002, Francisco Vaucher wrote:

    > Hi people, > > i've been searching for a while in google and vivisimo for docs that treats > paging techniques for php and mysql. And so far i seek nothing. I always get > stuck with empty documents (if you know what I mean). > > Can U give me a hand with this. If you already have a doc of this nature, or > the URL to get one ? > > Regards, and thanks in advance... > > Francisco M. Vaucher > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

    attached mail follows:


    > i've been searching for a while in google and vivisimo for docs that > treats > paging techniques for php and mysql. And so far i seek nothing. I always > get > stuck with empty documents (if you know what I mean). > > Can U give me a hand with this. If you already have a doc of this nature, > or > the URL to get one ?

    Good one here:

    http://www.phpbuilder.com/columns/rod20001214.php3

    may be a little dated with superglobals and register_globals, but you should get the idea...

    ---John Holmes...

    attached mail follows:


    I get this error from php when i execute this code can you help me ;) Warning: chdir() expects parameter 1 to be string, resource given in C:\xxxx\read.php on line 146

    145 echo "<center>Attachment :"; 146 $rep = opendir("C:\\xxx\\Attach\\$id\\"); 147 chdir($rep); 148 while ($zone = readdir($rep)) 149 { 150 if (!is_dir($zone)) echo "<a href=\"../Attach/$id/$zone\">$zone</a><br>"; 151 } 152 echo "</center>"; 153 }

    attached mail follows:


    Your code makes no sense and the error message is telling you exactly what you did wrong. opendir() returns a directory handle to be passed to readdir(). Calling chdir() on a directory handle makes no sense. You want to chdir to the same string that you passed to opendir()

    -Rasmus

    On Wed, 2 Oct 2002, Nokar wrote:

    > I get this error from php when i execute this code can you help me ;) > Warning: chdir() expects parameter 1 to be string, resource given in > C:\xxxx\read.php on line 146 > > 145 echo "<center>Attachment :"; > 146 $rep = opendir("C:\\xxx\\Attach\\$id\\"); > 147 chdir($rep); > 148 while ($zone = readdir($rep)) > 149 { > 150 if (!is_dir($zone)) echo "<a > href=\"../Attach/$id/$zone\">$zone</a><br>"; > 151 } > 152 echo "</center>"; > 153 } > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

    attached mail follows:


    Hi,

    Is it so that in php 4.2.3 we have to do both..."addslashes" and "removeslashes" ?? coz in one of the older versions the things are goin fine without using "removeslashes" but it doesnet seem to be the case in php4.2.2.

    thanx and regards anil

    attached mail follows:


    No, nothing has changed in recent memory with respect to this.

    On Wed, 2 Oct 2002, Anil Garg wrote:

    > Hi, > > Is it so that in php 4.2.3 we have to do both..."addslashes" and > "removeslashes" ?? coz in one of the older versions the things are goin fine > without using "removeslashes" but it doesnet seem to be the case in > php4.2.2. > > thanx and regards > anil > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

    attached mail follows:


    Hello,

    how can I use global variables in my web portal? I have read the php documentation, but it works only in the same file. I want use more global variable on many php site.

    For example: In login.php I use the code

    $first=mysql_result($result,0,"FIRST_NAME");

    and I want to print this $first variable all of my php site.

    Thanks!

    attached mail follows:


    As far as I know there is no way to set a site-wide global from within a script. Use PHP Sessions or set a Cookie and then print the variable in any script you want by calling $_SESSION['first'] or $COOKIES['first'];. But you'll need a starting point for your visitors in order for this to work.

    If your visitors will be accessing scripts at random you can do an include("setfirst.inc"); at the top of each script, where 'setfirst.inc' accesses the database and sets the $first variable each time a script is called.

    -Kevin

    ----- Original Message ----- From: "Anna Gyor" <bali1afreemail.hu> To: <php-generallists.php.net> Sent: Wednesday, October 02, 2002 2:06 PM Subject: [PHP] Global variables

    > Hello, > > how can I use global variables in my web portal? I have read the php > documentation, but it works only in the same file. > I want use more global variable on many php site. > > For example: > In login.php I use the code > > $first=mysql_result($result,0,"FIRST_NAME"); > > and I want to print this $first variable all of my php site. > > > Thanks! > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

    attached mail follows:


    > how can I use global variables in my web portal? I have read the php > documentation, but it works only in the same file. > I want use more global variable on many php site. > > For example: > In login.php I use the code > > $first=mysql_result($result,0,"FIRST_NAME"); > > and I want to print this $first variable all of my php site.

    You can't. You can, however, have a config.php or type page that's include()'d on every page in your site where you define these variables. For things like this that you draw from the database, it would be a good idea to query once and add to the session.

    I find it useful to use something like a $_CONF[] array.

    $_CONF['user'] = 'user'; $_CONF['path'] = '/home/user/htdocs/';

    etc...

    ---John Holmes...

    attached mail follows:


    On 2 Oct 2002 at 22:06, Anna Gyor wrote:

    > how can I use global variables in my web portal? I have read the php > documentation, but it works only in the same file. I want use more > global variable on many php site. > > For example: > In login.php I use the code > > $first=mysql_result($result,0,"FIRST_NAME"); > > and I want to print this $first variable all of my php site.

    Easy, use one script for your whole site.

    There is nothing that drives me more nuts than to encounter an application whose developers have left town and run into global variables. I don't mind file scoped variables so much, but to make a variable global across an application can drive one nuts when trying to debug.

    That said, I do use global variables but they are from a class whose 'object' is global. I don't have 3000 php files running all over my site as I've seen done. I have just a couple of *handlers* that use classes and I have one class which creates my global array which is shared. It's very easy to trace variables.

    I'd be very careful before I began to make variables global without some EASYmeans of tracing them. And it gets real interesting when one file inherits another which inherits another and in any one of them the value of your global variable can be changed. Does anyone know a good way for tracing such things?

    Peter

    attached mail follows:


    Hi,

    Thursday, October 3, 2002, 6:06:52 AM, you wrote: AG> Hello,

    AG> how can I use global variables in my web portal? I have read the php AG> documentation, but it works only in the same file. AG> I want use more global variable on many php site.

    AG> For example: AG> In login.php I use the code

    AG> $first=mysql_result($result,0,"FIRST_NAME");

    AG> and I want to print this $first variable all of my php site.

    AG> Thanks!

    If you are wanting it to be 'global' for the same visitor across your site use php session functions.

    -- 
    regards,
    Tom
    

    attached mail follows:


    I was able to work around this solution by using it on a different server with a different version of PHP. I decided to do this after reviewing the search results at Google.com This is a known bug that the PHP development team has chosen to ignore, as this article clearly outlines: http://www.phpbuilder.com/mail/php-developer-list/2001041/0904.php

    attached mail follows:


    Hi,

    I need to do either an insert or update into a MySQL table. Insert if there are 0 records or update if one record exist:

    This is my code snippet:

    if (mysql_query("SELECT COUNT(*) FROM AuthNum") == 0) { mysql_query("INSERT into AuthNum (FirstNum, LastNum, NextNum) VALUES (1,2,3)",$dblink); } else { mysql_query("Update AuthNum Set FirstNum = 1, LastNum = 2, NextNum = 3",$dbLink); }

    My problem is, a record never gets inserted because the SELECT COUNT query is returning a resource ID of 2. How can I get the actual number of records in the table?

    Thanks, Don

    attached mail follows:


    $result = mysql_query(); if (mysql_num_rows($result) > $x) -Kevin ----- Original Message ----- From: "DonPro" <donprolclcan.com> To: "php list" <php-generallists.php.net> Sent: Wednesday, October 02, 2002 2:35 PM Subject: [PHP] counting number of records in a MySQL table; how do I get the result?

    > Hi, > > I need to do either an insert or update into a MySQL table. Insert if there > are 0 records or update if one record exist: > > This is my code snippet: > > if (mysql_query("SELECT COUNT(*) FROM AuthNum") == 0) { > mysql_query("INSERT into AuthNum (FirstNum, LastNum, NextNum) VALUES > (1,2,3)",$dblink); > } else { > mysql_query("Update AuthNum Set FirstNum = 1, LastNum = 2, NextNum = > 3",$dbLink); > } > > My problem is, a record never gets inserted because the SELECT COUNT query > is returning a resource ID of 2. How can I get the actual number of records > in the table? > > Thanks, > Don > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

    attached mail follows:


    $ret = mysql_query("SELECT count(*) as foo FROM AuthNum"); $result = mysql_fetch_array($ret); echo $result['foo'];

    One of many ways...

    -Rasmus

    On Wed, 2 Oct 2002, DonPro wrote:

    > Hi, > > I need to do either an insert or update into a MySQL table. Insert if there > are 0 records or update if one record exist: > > This is my code snippet: > > if (mysql_query("SELECT COUNT(*) FROM AuthNum") == 0) { > mysql_query("INSERT into AuthNum (FirstNum, LastNum, NextNum) VALUES > (1,2,3)",$dblink); > } else { > mysql_query("Update AuthNum Set FirstNum = 1, LastNum = 2, NextNum = > 3",$dbLink); > } > > My problem is, a record never gets inserted because the SELECT COUNT query > is returning a resource ID of 2. How can I get the actual number of records > in the table? > > Thanks, > Don > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

    attached mail follows:


    > $result = mysql_query(); > if (mysql_num_rows($result) > $x) > -Kevin

    This won't work because a SELECT COUNT(*) query always returns a row, even if it returns zero as the value.

    $result = mysql_query("SELECT COUNT(*) FROM ... "); $count = mysql_result($result,0);

    ---John Holmes...

    > ----- Original Message ----- > From: "DonPro" <donprolclcan.com> > To: "php list" <php-generallists.php.net> > Sent: Wednesday, October 02, 2002 2:35 PM > Subject: [PHP] counting number of records in a MySQL table; how do I get > the > result? > > > > Hi, > > > > I need to do either an insert or update into a MySQL table. Insert if > there > > are 0 records or update if one record exist: > > > > This is my code snippet: > > > > if (mysql_query("SELECT COUNT(*) FROM AuthNum") == 0) { > > mysql_query("INSERT into AuthNum (FirstNum, LastNum, NextNum) VALUES > > (1,2,3)",$dblink); > > } else { > > mysql_query("Update AuthNum Set FirstNum = 1, LastNum = 2, NextNum = > > 3",$dbLink); > > } > > > > My problem is, a record never gets inserted because the SELECT COUNT > query > > is returning a resource ID of 2. How can I get the actual number of > records > > in the table? > > > > Thanks, > > Don > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

    attached mail follows:


    so why not take that resulting row, and then do an if on it to see if the value is a zero? an extra step, but it would work

    "John W. Holmes" <holmes072000charter.net> wrote in message news:002c01c26a66$61f0e1a0$7c02a8c0coconut... > > $result = mysql_query(); > > if (mysql_num_rows($result) > $x) > > -Kevin > > This won't work because a SELECT COUNT(*) query always returns a row, > even if it returns zero as the value. > > $result = mysql_query("SELECT COUNT(*) FROM ... "); > $count = mysql_result($result,0); > > ---John Holmes... > > > ----- Original Message ----- > > From: "DonPro" <donprolclcan.com> > > To: "php list" <php-generallists.php.net> > > Sent: Wednesday, October 02, 2002 2:35 PM > > Subject: [PHP] counting number of records in a MySQL table; how do I > get > > the > > result? > > > > > > > Hi, > > > > > > I need to do either an insert or update into a MySQL table. Insert > if > > there > > > are 0 records or update if one record exist: > > > > > > This is my code snippet: > > > > > > if (mysql_query("SELECT COUNT(*) FROM AuthNum") == 0) { > > > mysql_query("INSERT into AuthNum (FirstNum, LastNum, NextNum) > VALUES > > > (1,2,3)",$dblink); > > > } else { > > > mysql_query("Update AuthNum Set FirstNum = 1, LastNum = 2, > NextNum = > > > 3",$dbLink); > > > } > > > > > > My problem is, a record never gets inserted because the SELECT COUNT > > query > > > is returning a resource ID of 2. How can I get the actual number of > > records > > > in the table? > > > > > > Thanks, > > > Don > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > >

    attached mail follows:


    Here is the URL to a project that is far as I am concerned was finished. http://www.overbrookfarm.myiglou.com

    It is a Flash site that uses PHP for dynamically updating text in some text fields. If I can direct you to the Stallions menu---pick a horse. A page should load that has a picture of a horse on the left hand side and a green box on the right. The box on the right is dynamic text field. There should already be text inside of it.

    I see it. My 4 other PCs see it. About 5 people on this list can see it. A dozen of my friends can see it. The guy at tech support for where this is being hosted can see it. My client can't see it on his PC running IE5, but can see it on his Mac. His girlfriend can't see it, but one of his friends can.

    We had a fully working version up on a host that ran the PHP from Apache and everyone can see it. The site (and scripts) are now on a server that runs the PHP as CGI. It boggles the mind. Has anyone EVER heard of such a thing?? Are there security settings on the browser that won't let a CGI script execute, even from Flash?? Already made him clear his cache. Any ideas?

    Rebekah Garner

    attached mail follows:


    I took a course on PHP for Flash and the entire class ran into this problem. There was a problem with the Flash plug-in awhile back that was causing problems with dynamic text being loaded. Have your client download and install the most recent plug-in and that should fix the problem.

    ----- Original Message ----- From: "Rebekah Garner" <rebekahpowergothgirls.com> To: <php-generallists.php.net> Sent: Wednesday, October 02, 2002 3:42 PM Subject: [PHP] MORE Problems with PHP as CGI and Flash !!!!!!!!!!

    Here is the URL to a project that is far as I am concerned was finished. http://www.overbrookfarm.myiglou.com

    It is a Flash site that uses PHP for dynamically updating text in some text fields. If I can direct you to the Stallions menu---pick a horse. A page should load that has a picture of a horse on the left hand side and a green box on the right. The box on the right is dynamic text field. There should already be text inside of it.

    I see it. My 4 other PCs see it. About 5 people on this list can see it. A dozen of my friends can see it. The guy at tech support for where this is being hosted can see it. My client can't see it on his PC running IE5, but can see it on his Mac. His girlfriend can't see it, but one of his friends can.

    We had a fully working version up on a host that ran the PHP from Apache and everyone can see it. The site (and scripts) are now on a server that runs the PHP as CGI. It boggles the mind. Has anyone EVER heard of such a thing?? Are there security settings on the browser that won't let a CGI script execute, even from Flash?? Already made him clear his cache. Any ideas?

    Rebekah Garner

    attached mail follows:


    Extraordinarily helpful; thank you very much! Thanks to both Mike and Kevin on this.

    Jen

    > > > Why does this work: > > > > > > $contents = > > > > > eregi_replace("(\")(.(/))*[A-Z0-9_/-]+(.gif|.jpg)", > > > "\"blah.gif", $contents); > > > > > > But this does not: > > > > > > > > preg_match_all("(\")(.(/))*[A-Z0-9_/-]+(.gif|.jpg)", > > > $contents, $matches); > > > > > > for ($i=0; $i< count($matches[0]); $i++) { > > > echo "matched: ".$matches[0][$i]."\n" > > > } > > > > > > I get this error: > > > > > > Warning: Unknown modifier '(' in > > > /home/littleduck/www/www/newcontrol/temp/fread.php > > on > > > line 20 > > > > Well, first of all you've switched from a > > POSIX-extended regular expression > > function, eregi_replace(), to a Perl-compatible > > regular expression (PCRE) > > function, preg_match_all() -- all the POSIX-extended > > function names begin > > with an e, and all the PCRE ones with a p. The > > rules are different for the > > two sets, and one of the most important ones is that > > the PCRE functions > > require the pattern to be enclosed within > > delimiters, and the POSIX-extended > > ones don't (this is because you can add optional > > _modifiers_ after the > > ending delimiter for PCRE matching). The syntax of > > the regular expressions > > is also slightly different, and a pattern that works > > reliably for PCRE won't > > necessarily for POSIX-extended, and vice versa -- > > especially as PCRE is far > > more versatile and feature-rich. > > > > So, your basic problem in the preg_match_all() is > > that you haven't *added* > > delimiters -- the requirement is that you must use > > the same character both > > before and after your pattern, or a matched pair > > from one of the sets (), > > {}, [], and <>. So, the pattern parser is seeing the > > initial "(" in your > > expression, treating it as the opening delimiter, > > and taking your basic > > pattern to be the text up to the matching ")" -- > > that is, just (\"). It > > then looks to see if the next character is a valid > > _modifier_ (remember > > them?), finds "(" which isn't one, and complains -- > > and bingo!, there's your > > "Unknown modifier '('" message. > > > > So, this, for example, would work: > > > > > > > preg_match_all("{(\")(.(/))*[A-Z0-9_/-]+(.gif|.jpg)}", > > $contents, > > $matches); > > > > although I'd point out that "." is a > > pattern-matching element that means > > "any character", so you might prefer to escape it -- > > unfortunately, both > > regular expressions and PHP's double-quoted strings > > use \ as their escape > > character, so to get a single backslash into the > > expression to escape the > > ".", you've got to use two \\s (and to match an > > actual single backslash, you > > have to write no less than *four* backslashes!). So > > this would give: > > > > > > > preg_match_all("{(\")(\\.(/))*[A-Z0-9_/-]+(\\.gif|\\.jpg)}', > > $contents, > > $matches); > > > > Because of the problems with "backslash breeding" > > that this can cause, I'd > > always recommend using single-quoted strings for > > your patterns -- especially > > as, in this case, you have a double-quote in the > > pattern! Thus, my final > > effort would be: > > > > > > > preg_match_all('{(")(\.(/))*[A-Z0-9_/-]+(\.gif|\.jpg)}', > > $contents, > > $matches); > > > > Lastly, you may care to search the archives of this > > list for postings about > > the relative efficiency of the two types of > > expressions -- I know one set is > > frequently recommended as more efficient than the > > other, but can never > > remember which! > > > > Hope this is helpful, > > > > Cheers! > > > > Mike

    attached mail follows:


    hi,

    i'm running PHP 4.0.6 with apache on RedHat 7.2 , error_reporing is set to default(2039) in the php.ini file : my script is as follows :

    <? qwe;

    dsf ?>

    But i dont get even a parse error or anything

    Any clues to what is going wrong ?

    thx

    gamin.

    attached mail follows:


    Check ur php.ini, there are settings to display showing absolutly any error, warning, and message. they are probaly set to not show them.

    error_reporting = E_ALL & ~E_NOTICE

    thats what i use, only displays what i need

    Jason Reid jasonachost.ca

    --
    AC Host Canada
    www.achost.ca
    

    ----- Original Message ----- From: "gamin" <gaminvsnl.net> To: <php-generallists.php.net> Sent: Wednesday, October 02, 2002 3:51 PM Subject: [PHP] no errors ?

    > hi, > > i'm running PHP 4.0.6 with apache on RedHat 7.2 , error_reporing is set to > default(2039) in the php.ini file : > my script is as follows : > > <? > qwe; > > > dsf > ?> > > But i dont get even a parse error or anything > > Any clues to what is going wrong ? > > thx > > gamin. > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

    attached mail follows:


    Shot in the dark that may or may not help... Look into display_errors and log_errors. I think those are the names. They control where error output goes.

    Cheers, Rob.

    gamin wrote: > > hi, > > i'm running PHP 4.0.6 with apache on RedHat 7.2 , error_reporing is set to > default(2039) in the php.ini file : > my script is as follows : > > <? > qwe; > > dsf > ?> > > But i dont get even a parse error or anything > > Any clues to what is going wrong ? > > thx > > gamin. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

    -- 
    .-----------------.
    | Robert Cummings |
    :-----------------`----------------------------.
    | Webdeployer - Chief PHP and Java Programmer  |
    :----------------------------------------------:
    | Mail  : mailto:robert.cummingswebmotion.com |
    | Phone : (613) 731-4046 x.109                 |
    :----------------------------------------------:
    | Website : http://www.webmotion.com           |
    | Fax     : (613) 260-9545                     |
    `----------------------------------------------'
    

    attached mail follows:


    Yes,

    On both my development machine and implmetation machine i have the same error_reporting. error_reporing = 2039 (that is what phpinfo() gives me ) is equivalent to E_ALL^E_NOTICE. And still i cant seem to get any error, even on a winxp system running Apache and PHP 4.2.1 (from the php.ini file) -

    error_reporting = E_ALL & ~E_NOTICE

    I still cant understand why PHP is not complaining ?

    thx

    gamin.

    attached mail follows:


    I noticed that by default, my display_errors was actually OFF, and the only way to see my errors was through Apache's error.log file

    I don't know if that's already been checked, but... figured I'd try to help.

    -Jason

    Gamin wrote: > Yes, > > On both my development machine and implmetation machine i have the same > error_reporting. > error_reporing = 2039 (that is what phpinfo() gives me ) is equivalent > to E_ALL^E_NOTICE. And still i cant seem to get any error, even on a winxp > system running Apache and PHP 4.2.1 (from the php.ini file) - > > error_reporting = E_ALL & ~E_NOTICE > > I still cant understand why PHP is not complaining ? > > thx > > gamin. > >

    attached mail follows:


    -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

    Hey, Is short_tags on? ~Pauly

    On Wednesday 02 October 2002 05:51 pm, gamin wrote: > hi, > > i'm running PHP 4.0.6 with apache on RedHat 7.2 , error_reporing is set > to default(2039) in the php.ini file : > my script is as follows : > > <? > qwe; > > > dsf > ?> > > But i dont get even a parse error or anything > > Any clues to what is going wrong ? > > thx > > gamin.

    - -- ~Paul Nicholson Design Specialist WebPower Design "The web....the way you want it!" paulwebpowerdesign.net

    "It said uses Windows 98 or better, so I loaded Linux!" Registered Linux User #183202 using Register Linux System # 81891 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org

    iD8DBQE9m3xHDyXNIUN3+UQRAn1NAJ0S3zXi7JQ9OPg2/m9B1Vx4NHu/wQCeJQwR 8KACs0TmgDXQunDdRI7DHT4= =b7S7 -----END PGP SIGNATURE-----

    attached mail follows:


    Hi!

    I had PHP compiled with the "--with-mcrypt" option. So, when I use this script, PHP spit out the error " Warning: could not open encryption module" but it work fine if I use other script like "$SSL_CIPHER_USEKEYSIZE".

    --clip-- mcrypt_module_open(MCRYPT_TripleDES, "", MCRYPT_MODE_ECB, ""); --clip--

    Why is that? The mcrypt is already compiled with PHP.......

    attached mail follows:


    Hi,

    My hosting provider still using CGI as Server API. I think this is way too much dropped behind. On my own development server I use Apache as Server API. However, maybe this could be a kind of consideration for the situation that multi-sites hosted on one server? I am thinking I'd better learn something before I ask my hosting provier. Thanks!

    Alex Shi

    --
    ---------------------------
    TrafficBuilder Network:
    http://www.bestadv.net/index.cfm?ref=7029
    

    attached mail follows:


    I'm getting much closer to achieving my goal here. Now, I'm missing yet one more element. Here is my code:

    ---------- $filename = "newexample.html";

    $fd = fopen ($filename, "r");

    $contents = fread ($fd, filesize ($filename));

    preg_match_all('{\/*[A-z0-9_/-]+(.gif|.jpg)}', $contents, $matches);

    for ($i=0; $i< count($matches[0]); $i++) {

    echo "matched: ".$matches[0][$i]."<br>\n";

    $blah = basename($matches[0][$i]);

    $contents = eregi_replace('\/*[A-z0-9_/-]+(.gif|.jpg)', $blah, $contents); }

    print $contents;

    fclose ($fd); ----------

    In this PHP script I am reading in the contents from "newexample.html", going through it and looking for image strings ("something/.../imagename.gif|jpg"), and stripping them down to their basenames ("imagename.gif|jpg"). What I must ALSO do is print the contents of the html file with the new, stripped down image strings. What's going on in the above code is that each time you get to:

    $contents = eregi_replace('\/*[A-z0-9_/-]+(.gif|.jpg)', $blah, $contents);

    it goes through the entire html file and replaces every image string with the same replacement, so when the script is done executing, every image string in the html file is identical. Of course, what I *want* to do is replace them all individually. So if the html file has:

    <img src="images/imagename.gif"> <img src="imagename2.jpg"> <img src="images/2/imagename3.gif">

    I want those strings to be replaced with:

    <img src="imagename.gif"> <img src="imagename2.jpg"> <img src="imagename3.gif">

    But, the code as I have it is just replacing them all with <img src="imagename3.gif"> since it was the last one to have matched.

    How might I go through and replace them one by one? Obscure hints are welcome. :)

    Thanks, Jen

    attached mail follows:


    > I am the webmaster of the site, i pay for the server space, > is that what you mean?

    First up Simon, I deleted over a hundred lines of no longer relevant content from your message including things like signatures. You should probably trim messages down when you reply to them...

    Next up, when you say you are the webmaster, what does that mean? What sort of access do you have to the server? Can you connect to the server using ssh? Or do you only have access to uploading files using ftp? If the former, you can check permissions (which is almost certainly where your problem is) and act from the information you find. If you don't have ssh-style access then you'll likely be stuck with work-arounds to make things like this do what you want.

    Do you understand the concept of users, groups and permissions? This is a *nix thing that is not as common on Windows platforms but is of critical importance when you start looking at issues like file creation, particiularly in automated scripts, on a *nix box. If you understand them then I won't bother going further, if you don't then this is probably where your starting point needs to be so that you understand why the problem is occuring and will be able to deal with it in future situations that you'll almost certainly run into.

    Oh, and if you have ssh-style access then the ftp thing you're trying to do in php should really be done in other ways - the BoM web servers are loaded enough without receiving a hit every time someone loads your page.

    CYA, Dave

    attached mail follows:


    I am having problems with arrays. I guess I just don't understand them all that well. I have an simple array of stock tickers. Then for each ticker I go to Yahoo to get their current price and try to push the Name of the ticker and it's value into an associative array(I think). Then I want to sort the array so the the values are in order from highest to lowest, so I can see the highest amount as the first position and the lowest as the last position.

    Here is my problem; for debuggin purposes I do a print_r(array_values()); and I get the following for output. Array ( [0] => 7.28 [1] => 5.20 [2] => 1.969 [3] => 59.63 [4] => 4.43 )

    I am not sure why I am getting this. I guess I expected the numerical positions to be the keys something like: Array ( [ikn] => 7.28 [xrx] => 5.20 [danky] => 1.969 [ibm] => 59.63 [rhat] => 4.43 )

    Since I am not getting the results I expected I am not sure if the rest is working correctly because I do not know how to access the first position in the array, or the last. When I get this working, I will be adding 200 tickers and I would like to get the first 5 and the last 5, expecting them to be the highest 5 and the lowest 5 respectively. I hope someone will take the time to halp me.

    Thank you in advance.

    Here is the code I am working on:

    $Tickers = array("ikn", "xrx", "danky", "ibm", "rhat"); $TickersCurrent = array();

    foreach($Tickers as $Ticker) { $LookupUrl = "http://finance.yahoo.com/d/quotes.csv?s=$Ticker&f=l1&e=.txt"; $Current = implode('', file("$LookupUrl")); $Current = rtrim($Current); $TickersCurrent["$Ticker"]=$Current; }

    // Done for debuggin only print "<pre>\n"; print_r(array_values($TickersCurrent)); print "</pre>\n";

    asort ($TickersCurrent); reset ($TickersCurrent);

    echo "CTC Indice = " . array_sum($TickersCurrent) . "<br>\n";

    echo "The highest Stock is $TickersCurrent[0]";

    attached mail follows:


    It looks like your problem is simply in the debug line, where you echo print_r(array_values($TickersCurrent)); You shouldn't call array_values() before print_r(), since array_values generates an indexed array of only the values (quotes), not the keys (tickers), of the supplied array, essentially taking your quotes from your ticker=>quote pairs and replacing the tickers with an index. Just do print_r($TickersCurrent) and you'll get the desired result. Hope that helps, Andy

    -----Original Message----- From: Christopher J. Crane [mailto:ccraneinxdesign.com] Sent: Wednesday, October 02, 2002 8:16 PM To: php-generallists.php.net Subject: [PHP] Trouble with understanding arrays

    I am having problems with arrays. I guess I just don't understand them all that well. I have an simple array of stock tickers. Then for each ticker I go to Yahoo to get their current price and try to push the Name of the ticker and it's value into an associative array(I think). Then I want to sort the array so the the values are in order from highest to lowest, so I can see the highest amount as the first position and the lowest as the last position.

    Here is my problem; for debuggin purposes I do a print_r(array_values()); and I get the following for output. Array ( [0] =>