PHP Knowledge Base Update -- June 28th, 1999

[email protected] (Nathan Wallace) Tue, 29 Jun 1999 11:22:30 -0500
Newsgroups php.kb
Message-ID <[email protected]>
Things may take a little while to settle down as I work to find the best
format and content for this list.  Please don't hesitate to send me your
suggestions.  I am not yet including recently edited or random knowledge
base entries in this mail.  I'll add those sections soon.

Jim Winstead announced today the release of PHP 3.0.11.  It is
downloadable from http://www.php.net.

There is no fixed time when I send summaries.  It really just depends on
what time I can drag myself out of bed after coding all night and on
factors like the reliability of my ISP.

Remember that anyone can contribute to the knowledge base.  If you see
something that's wrong, incomplete or badly explained, fix it!  If you
are researching PHP information, summarise your findings in the
knowledge base.  Best of all, you don't have to worry too much about
getting it wrong because people will no doubt correct you.  Have a go:

    http://e-gineer.com/phpkb/


Cheers,

Nathan


------------------------------------------------------------
How can I get the IP address of a visitor?
What is the REMOTE_ADDR?
How can I get the domain name of a visiting client browser?
http://e-gineer.com/phpkb/view.phtml/qid/225
------------------------------------------------------------
John Coggeshall, Rod, Sascha Schumann

PHP makes this information automatically available in variables:

    $REMOTE_ADDR - the IP address of the client
    $REMOTE_HOST - the host address of the client, if available

You can also get this type of information using getenv().

    http://www.php.net/manual/function.getenv.php3

To see what information like this is available create a page that
contains just:

    <?php phpinfo() ?>

That will show you all of the environment variables that are available.

If your server doesn't look up the host name of the client automatically
then gethostbyaddr() might be useful:

    http://www.php.net/manual/function.gethostbyaddr.php3


------------------------------------------------------------
How can I uninstall a RPM?
http://e-gineer.com/phpkb/view.phtml/qid/229
------------------------------------------------------------
M.Brands

You can uninstall a package with:

    rpm -e <packagename>

To find the correct package name for PHP, do a:

    rpm -qa|grep php


------------------------------------------------------------
What does the _register_frame_info error when I run Apache mean?
http://e-gineer.com/phpkb/view.phtml/qid/230
------------------------------------------------------------
Sascha Schumann

If you get the following error when trying to run the Apache binary:

ld.so.1: ./httpd: fatal: relocation error: file ./httpd: symbol
__register_frame_info: referenced symbol not found

Then it's probably an ugly compiler/libc problem. 

    http://sourceware.cygnus.com/glibc/glibc-faq.html#s-2.8

Upgrading to the latest glibc should help.


------------------------------------------------------------
What does the _xstat error when I run Apache mean?
http://e-gineer.com/phpkb/view.phtml/qid/231
------------------------------------------------------------
Sascha Schumann

Here is an example error message:

    Can't load /etc/httpd/modules/libphp3.so into server:
    /etc/httpd/modules/libphp3.so: undefined simbol: _xstat

Missing _xstat symbols are mostly due to a broken libc
installation, e.g. compiling against glibc 2.1 headers and
linking with glibc 2.0 will lead to such an error.


------------------------------------------------------------
What is leak() used for?
http://e-gineer.com/phpkb/view.phtml/qid/232
------------------------------------------------------------
Adam Whitehead, Sascha Schumann

"Leak() leaks the specified amount of memory."

    http://www.php.net/manual/function.leak.php3

A leak is something which allocates a resource (in this case
memory) and loses all references to it. For example

my_leak() {
        char *c;

        while(1) c = malloc(1024);
}

Basically don't worry about it, it's mostly used for debugging purposes.


------------------------------------------------------------
How can I check safely that strpos found the string?
What happens when strpos finds a string at position zero?
http://e-gineer.com/phpkb/view.phtml/qid/235
------------------------------------------------------------
Keith Edmunds

Taken from

    http://www.php.net/manual/function.strpos.php3

Note that strpos' character index is zero-based; a character match on
the first character returns zero (strpos('ab', 'a') = 0). Thus, a test
such as:

    if (strpos($hay, $needle)) { ... }

can give a false negative. You can use the empty() function or an
explicit test (strpos(...) >= 0) to avoid this.


------------------------------------------------------------
How can I remember data from the first page through a multi-page form?
http://e-gineer.com/phpkb/view.phtml/qid/237
------------------------------------------------------------
Nathan Wallace

Using hidden fields is the best way to pass and keep data through your
multi-page forms.  For example:

    <input type=hidden name="firstformvar" value="<? echo $var ?>">

You should probably check that the input from the user is valid
immediately after they enter it, that way you can report any errors
straight away.

If you are really paranoid then you should recheck all of the
information at the end of your form sequence.  Malicious users could
hack the html source and change the hidden fields to suit their needs.


------------------------------------------------------------
Can I run both PHP2/FI and PHP3 on the same machine?
http://e-gineer.com/phpkb/view.phtml/qid/238
------------------------------------------------------------
Stephen Benjamin

Just install both.  PHP2 files should have the extension .phtml and PHP3
should use .php3 or .php.


------------------------------------------------------------
How do I escape quotes in strings sent to Microsoft Access?
http://e-gineer.com/phpkb/view.phtml/qid/239
------------------------------------------------------------
Andrew Smith

Microsoft Access doesn't use an escape character (like backslash '\')
instead you put 2 single quotes side by side to escape.

E.g.  "now I know why it didn''t work"


------------------------------------------------------------
Where can I find the values of nameless arguments in a GET request?
How can I find out if bar exists for a request like http://foo.com?bar?
http://e-gineer.com/phpkb/view.phtml/qid/240
------------------------------------------------------------
Chad

script.php3?first&second&third

$argv[0] is first
$argv[1] is second
$argv[2] is third