cvs: phpdoc-es /faq build.xml com.xml databases.xml general.xml html.xml installation.xml languages.xml mailinglist.xml migration.xml migration4.xml
misc.xml obtaining.xml using.xml
| From: | Pablo Rigazzi | Date: | Sun, 11 May 2003 22:37:32 +0000 |
| Subject: | cvs: phpdoc-es /faq build.xml com.xml databases.xml general.xml html.xml installation.xml languages.xml mailinglist.xml migration.xml migration4.xml misc.xml obtaining.xml using.xml |
||
| Groups: | php.doc.es | ||
| Request: | Send a blank email to doc-es+get-188@lists.php.net to get a copy of this message | ||
webstudio Sun May 11 18:37:32 2003 EDT
Added files:
/phpdoc-es/faq build.xml com.xml databases.xml general.xml html.xml
installation.xml languages.xml mailinglist.xml
migration.xml migration4.xml misc.xml obtaining.xml
using.xml
Log:
Agregando versiones iniciales de faq.*
Index: phpdoc-es/faq/build.xml +++ phpdoc-es/faq/build.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.build"> <title>Build Problems</title> <titleabbrev>Build Problems</titleabbrev> <para> This section gathers most common errors that occur at build time. </para> <qandaset> <qandaentry id="faq.build.configure"> <question> <para> I got the latest version of PHP using the anonymous CVS service, but there's no configure script! </para> </question> <answer> <para> You have to have the GNU autoconf package installed so you can generate the configure script from <filename>configure.in</filename>. Just run <command>./buildconf</command> in the top-level directory after getting the sources from the CVS server. (Also, unless you run configure with the <literal>--enable-maintainer-mode</literal> option, the configure script will not automatically get rebuilt when the <filename>configure.in</filename> file is updated, so you should make sure to do that manually when you notice configure.in has changed. One symptom of this is finding things like @VARIABLE@ in your Makefile after configure or <filename>config.status</filename> is run.) </para> </answer> </qandaentry> <qandaentry id="faq.build.configuring"> <question> <para> I'm having problems configuring PHP to work with Apache. It says it can't find <filename>httpd.h</filename>, but it's right where I said it is! </para> </question> <answer> <para> You need to tell the configure/setup script the location of the top-level of your Apache source tree. This means that you want to specify <literal>--with-apache=/path/to/apache</literal> and <emphasis>not</emphasis> <literal>--with-apache=/path/to/apache/src</literal>. </para> </answer> </qandaentry> <qandaentry id="faq.build.lex"> <question> <para> While configuring PHP (<literal>./configure</literal>), you come across an error similar to the following: </para> <para> <screen> checking lex output file root... ./configure: lex: command not found configure: error: cannot find output from lex; giving up </screen> </para> </question> <answer> <para> Be sure to read the <link linkend="install.unix">installation</link> instructions carefully and note that you need both flex and bison installed to compile PHP. Depending on your setup you will install bison and flex from either source or a package, such as a RPM. </para> </answer> </qandaentry> <qandaentry id="faq.build.apache-sharedcore"> <question> <para> When I try to start Apache, I get the the following message: </para> <para> <screen> fatal: relocation error: file /path/to/libphp4.so: symbol ap_block_alarms: referenced symbol not found </screen> </para> </question> <answer> <para> This error usually comes up when one compiles the Apache core program as a DSO library for shared usage. Try to reconfigure apache, making sure to use at least the following flags: </para> <para> <screen> --enable-shared=max --enable-rule=SHARED_CORE </screen> </para> <para> For more information, read the top-level Apache <filename>INSTALL</filename> file or the Apache <ulink url="&url.apachedso;">DSO manual page</ulink>. </para> </answer> </qandaentry> <qandaentry id="faq.build.not-found"> <question> <para> When I run configure, it says that it can't find the include files or library for GD, gdbm, or some other package! </para> </question> <answer> <para> You can make the configure script looks for header files and libraries in non-standard locations by specifying additional flags to pass to the C preprocessor and linker, such as: <programlisting> <![CDATA[ CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure ]]> </programlisting> If you're using a csh-variant for your login shell (why?), it would be: <programlisting> <![CDATA[ env CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure ]]> </programlisting> </para> </answer> </qandaentry> <qandaentry id="faq.build.yytname"> <question> <para> When it is compiling the file <filename>language-parser.tab.c</filename>, it gives me errors that say <literal>yytname undeclared</literal>. </para> </question> <answer> <para> You need to update your version of Bison. You can find the latest version at <ulink url="&url.bison;">&url.bison;</ulink>. </para> </answer> </qandaentry> <qandaentry id="faq.build.link"> <question> <para> When I run <command>make</command>, it seems to run fine but then fails when it tries to link the final application complaining that it can't find some files. </para> </question> <answer> <para> Some old versions of make that don't correctly put the compiled versions of the files in the functions directory into that same directory. Try running <command>cp *.o functions</command> and then re-running <command>make</command> to see if that helps. If it does, you should really upgrade to a recent version of GNU make. </para> </answer> </qandaentry> <qandaentry id="faq.build.undefined"> <question> <para> When linking PHP, it complains about a number of undefined references. </para> </question> <answer> <para> Take a look at the link line and make sure that all of the appropriate libraries are being included at the end. Common ones that you might have missed are '-ldl' and any libraries required for any database support you included. </para> <para> If you're linking with Apache 1.2.x, did you remember to add the appropriate information to the EXTRA_LIBS line of the Configuration file and re-rerun Apache's Configure script? See the <ulink url="&url.file.installation;">INSTALL</ulink> file that comes with the distribution for more information. </para> <para> Some people have also reported that they had to add '-ldl' immediately following <filename>libphp4.a</filename> when linking with Apache. </para> </answer> </qandaentry> <qandaentry id="faq.build.Apache"> <question> <para> I can't figure out how to build PHP with Apache 1.3. </para> </question> <answer> <para> This is actually quite easy. Follow these steps carefully: <itemizedlist> <listitem> <simpara> Grab the latest Apache 1.3 distribution from <ulink url="&url.apache.source;">&url.apache.source;</ulink>. </simpara> </listitem> <listitem> <simpara> Ungzip and untar it somewhere, for example <filename>/usr/local/src/apache-1.3</filename>. </simpara> </listitem> <listitem> <simpara> Compile PHP by first running <command>./configure --with-apache=/<path>/apache-1.3</command> (substitute <path> for the actual path to your apache-1.3 directory. </simpara> </listitem> <listitem> <simpara> Type <command>make</command> followed by <command>make install</command> to build PHP and copy the necessary files to the Apache distribution tree. </simpara> </listitem> <listitem> <simpara> Change directories into to your <filename>/<path>/apache-1.3/src</filename> directory and edit the <filename>Configuration</filename> file. Add to the file: <literal>AddModule modules/php4/libphp4.a</literal>. </simpara> </listitem> <listitem> <simpara> Type: <command>./configure</command> followed by <literal>make</literal>. </simpara> </listitem> <listitem> <simpara> You should now have a PHP-enabled httpd binary! </simpara> </listitem> </itemizedlist> </para> <para> <emphasis>Note:</emphasis> You can also use the new Apache <literal>./configure</literal> script. See the instructions in the <literal>README.configure</literal> file which is part of your Apache distribution. Also have a look at the <filename>INSTALL</filename> file in the PHP distribution. </para> </answer> </qandaentry> <qandaentry id="faq.build.not-running"> <question> <para> I have followed all the steps to install the Apache module version on UNIX, and my PHP scripts show up in my browser or I am being asked to save the file. </para> </question> <answer> <para> This means that the PHP module is not getting invoked for some reason. Three things to check before asking for further help: <itemizedlist> <listitem> <simpara> Make sure that the httpd binary you are running is the actual new httpd binary you just built. To do this, try running: <literal>/path/to/binary/httpd -l</literal> </simpara> <simpara> If you don't see <filename>mod_php4.c</filename> listed then you are not running the right binary. Find and install the correct binary. </simpara> </listitem> <listitem> <simpara> Make sure you have added the correct Mime Type to one of your <literal>Apache .conf</literal> files. It should be: <literal>AddType application/x-httpd-php3 .php3</literal> (for PHP 3) </simpara> <simpara> or <literal>AddType application/x-httpd-php .php</literal> (for PHP 4) </simpara> <simpara> Also make sure that this AddType line is not hidden away inside a <Virtualhost> or <Directory> block which would prevent it from applying to the location of your test script. </simpara> </listitem> <listitem> <simpara> Finally, the default location of the Apache configuration files changed between Apache 1.2 and Apache 1.3. You should check to make sure that the configuration file you are adding the AddType line to is actually being read. You can put an obvious syntax error into your httpd.conf file or some other obvious change that will tell you if the file is being read correctly. </simpara> </listitem> </itemizedlist> </para> </answer> </qandaentry> <qandaentry id="faq.build.activate-module"> <question> <para> It says to use: <literal>--activate-module=src/modules/php4/libphp4.a</literal>, but that file doesn't exist, so I changed it to <literal>--activate-module=src/modules/php4/libmodphp4.a</literal> and it doesn't work!? What's going on? </para> </question> <answer> <para> Note that the <filename>libphp4.a</filename> file is not supposed to exist. The apache process will create it! </para> </answer> </qandaentry> <qandaentry id="faq.build.ansi"> <question> <para> When I try to build Apache with PHP as a static module using <literal>--activate-module=src/modules/php4/libphp4.a</literal> it tells me that my compiler is not ANSI compliant. </para> </question> <answer> <para> This is a misleading error message from Apache that has been fixed in more recent versions. </para> </answer> </qandaentry> <qandaentry id="faq.build.apxs"> <question> <para> When I try to build PHP using <literal>--with-apxs</literal> I get strange error messages. </para> </question> <answer> <para> There are three things to check here. First, for some reason when Apache builds the apxs Perl script, it sometimes ends up getting built without the proper compiler and flags variables. Find your apxs script (try the command <command>which apxs</command>), it's sometimes found in <filename>/usr/local/apache/bin/apxs</filename> or <filename>/usr/sbin/apxs</filename>. Open it and check for lines similar to these: <programlisting> <![CDATA[ my $CFG_CFLAGS_SHLIB = ' '; # substituted via Makefile.tmpl my $CFG_LD_SHLIB = ' '; # substituted via Makefile.tmpl my $CFG_LDFLAGS_SHLIB = ' '; # substituted via Makefile.tmpl ]]> </programlisting> If this is what you see, you have found your problem. They may contain just spaces or other incorrect values, such as 'q()'. Change these lines to say: <programlisting> <![CDATA[ my $CFG_CFLAGS_SHLIB = '-fpic -DSHARED_MODULE'; # substituted via Makefile.tmpl my $CFG_LD_SHLIB = 'gcc'; # substituted via Makefile.tmpl my $CFG_LDFLAGS_SHLIB = q(-shared); # substituted via Makefile.tmpl ]]> </programlisting> The second possible problem should only be an issue on Red Hat 6.1 and 6.2. The apxs script Red Hat ships is broken. Look for this line: <programlisting> <![CDATA[ my $CFG_LIBEXECDIR = 'modules'; # substituted via APACI install ]]> </programlisting> If you see the above line, change it to this: <programlisting> <![CDATA[ my $CFG_LIBEXECDIR = '/usr/lib/apache'; # substituted via APACI install ]]> </programlisting> Last, if you reconfigure/reinstall Apache, add a <command>make clean</command> to the process after <command>./configure</command> and before <command>make</command>. </para> </answer> </qandaentry> <qandaentry id="faq.build.microtime"> <question> <para> During <command>make</command>, I get errors in microtime, and a lot of <literal>RUSAGE_</literal> stuff. </para> </question> <answer> <para> During the <command>make</command> portion of installation, if you encounter problems that look similar to this: <programlisting> <![CDATA[ microtime.c: In function `php_if_getrusage': microtime.c:94: storage size of `usg' isn't known microtime.c:97: `RUSAGE_SELF' undeclared (first use in this function) microtime.c:97: (Each undeclared identifier is reported only once microtime.c:97: for each function it appears in.) microtime.c:103: `RUSAGE_CHILDREN' undeclared (first use in this function) make[3]: *** [microtime.lo] Error 1 make[3]: Leaving directory `/home/master/php-4.0.1/ext/standard' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/home/master/php-4.0.1/ext/standard' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/master/php-4.0.1/ext' make: *** [all-recursive] Error 1 ]]> </programlisting> </para> <para> Your system is broken. You need to fix your <filename>/usr/include</filename> files by installing a glibc-devel package that matches your glibc. This has absolutely nothing to do with PHP. To prove this to yourself, try this simple test: <programlisting> <![CDATA[ $ cat >test.c <<X #include <sys/resource.h> X $ gcc -E test.c >/dev/null ]]> </programlisting> If that spews out errors, you know your include files are messed up. </para> </answer> </qandaentry> <qandaentry id="faq.build.mysql.tempnam"> <question> <para> When compiling PHP with MySQL, configure runs fine but during <literal>make</literal> I get an error similar to the following: <emphasis>ext/mysql/libmysql/my_tempnam.o(.text+0x46): In function my_tempnam': /php4/ext/mysql/libmysql/my_tempnam.c:103: the use of tempnam' is dangerous, better use mkstemp'</emphasis>, what's wrong? </para> </question> <answer> <para> First, it's important to realize that this is a <literal> Warning</literal> and not a fatal error. Because this is often the last output seen during <literal>make</literal>, it may seem like a fatal error but it's not. Of course, if you set your compiler to die on Warnings, it will. Also keep in mind that MySQL support is enabled by default. </para> </answer> </qandaentry> <qandaentry id="faq.build.upgrade"> <question> <para> I want to upgrade my PHP. Where can I find the <command>./configure</command> line that was used to build my current PHP installation? </para> </question> <answer> <para> Either you look at config.nice file, in the source tree of your current PHP installation or, if this is not available, you simply run a <programlisting> <![CDATA[ <?php phpinfo(); ?> ]]> </programlisting> script. On top of the output the <command>./configure</command> line, that was used to build this PHP installation is shown. </para> </answer> </qandaentry> <qandaentry id="faq.build.gdlibs"> <question> <para> When building PHP with the GD library it either gives strange compile errors or segfaults on execution. </para> </question> <answer> <para> Make sure your GD library and PHP are linked against the same depending libraries (e.g. libpng). </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/com.xml +++ phpdoc-es/faq/com.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.com"> <title>PHP and COM</title> <titleabbrev>PHP and COM</titleabbrev> <para> PHP can be used to access COM and DCOM objects on Win32 platforms. </para> <qandaset> <qandaentry id="faq.com.q1"> <question> <para> I have built a DLL to calculate something. Is there any way to run this DLL under PHP ? </para> </question> <answer> <para> If this is a simple DLL there is no way yet to run it from PHP. If the DLL contains a COM server you may be able to access it if it implements the IDispatch interface. </para> </answer> </qandaentry> <qandaentry id="faq.com.q2"> <question> <para> What does 'Unsupported variant type: xxxx (0xxxxx)' mean ? </para> </question> <answer> <para> There are dozens of VARIANT types and combinations of them. Most of them are already supported but a few still have to be implemented. Arrays are not completely supported. Only single dimensional indexed only arrays can be passed between PHP and COM. If you find other types that aren't supported, please report them as a bug (if not already reported) and provide as much information as available. </para> </answer> </qandaentry> <qandaentry id="faq.com.q3"> <question> <para> Is it possible manipulate visual objects in PHP ? </para> </question> <answer> <para> Generally it is, but as PHP is mostly used as a web scripting language it runs in the web servers context, thus visual objects will never appear on the servers desktop. If you use PHP for application scripting e.g. in conjunction with PHP-GTK there is no limitation in accessing and manipulating visual objects through COM. </para> </answer> </qandaentry> <qandaentry id="faq.com.q4"> <question> <para> Can I store a COM object in a session ? </para> </question> <answer> <para> No, you can't. COM instances are treated as resources and therefore they are only available in a single script's context. </para> </answer> </qandaentry> <qandaentry id="faq.com.q5"> <question> <para> How can I trap COM errors ? </para> </question> <answer> <para> Currently it's not possible to trap COM errors beside the ways provided by PHP itself (@, track_errors, ..), but we are thinking of a way to implement this. </para> </answer> </qandaentry> <qandaentry id="faq.com.q6"> <question> <para> Can I generate DLL files from PHP scripts like i can in Perl ? </para> </question> <answer> <para> No, unfortunately there is no such tool available for PHP. </para> </answer> </qandaentry> <qandaentry id="faq.com.q7"> <question> <para> What does 'Unable to obtain IDispatch interface for CLSID {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}' mean ? </para> </question> <answer> <para> This error can have multiple reasons: <itemizedlist> <listitem> <simpara> the CLSID is wrong </simpara> </listitem> <listitem> <simpara> the requested DLL is missing </simpara> </listitem> <listitem> <simpara> the requested component doesn't implement the IDispatch interface </simpara> </listitem> </itemizedlist> </para> </answer> </qandaentry> <qandaentry id="faq.com.q8"> <question> <para> How can I run COM object from remote server ? </para> </question> <answer> <para> Exactly like you run local objects. You only have to pass the IP of the remote machine as second parameter to the COM constructor. </para> <para> Make sure that you have set <literal>com.allow_dcom=true</literal> in your &php.ini;. </para> </answer> </qandaentry> <qandaentry id="faq.com.q9"> <question> <para> I get 'DCOM is disabled in C:\path...\scriptname.php on line 6', what can I do ? </para> </question> <answer> <para> Edit your &php.ini; and set <literal>com.allow_dcom=true</literal>. </para> </answer> </qandaentry> <qandaentry id="faq.com.q10"> <question> <para> Is it possible to load/manipulate an ActiveX object in a page with PHP ? </para> </question> <answer> <para> This has nothing to do with PHP. ActiveX objects are loaded on client side if they are requested by the HTML document. There is no relation to the PHP script and therefore there is no direct server side interaction possible. </para> </answer> </qandaentry> <qandaentry id="faq.com.q11"> <question> <para> Is it possible to get a running instance of a component ? </para> </question> <answer> <para> This is possible with the help of monikers. If you want to get multiple references to the same word instance you can create that instance like shown: </para> <programlisting role="php"> $word = new COM("C:\docs\word.doc"); </programlisting> <para> This will create a new instance if there is no running instance available or it will return a handle to the running instance, if available. </para> </answer> </qandaentry> <qandaentry id="faq.com.q12"> <question> <para> Is there a way to handle an event sent from COM object ? </para> </question> <answer> <para> Starting in PHP 4.3.0, you can define an event sink and bind it as shown in the example below. You can use <function>com_print_typeinfo</function> to have PHP generate a skeleton for the event sink class. <example> <title>COM event sink example</title> <programlisting role="php"> <![CDATA[ <?php class IEEventSinker { var $terminated = false; function ProgressChange($progress, $progressmax) { echo "Download progress: $progress / $progressmax\n"; } function DocumentComplete(&$dom, $url) { echo "Document $url complete\n"; } function OnQuit() { echo "Quit!\n"; $this->terminated = true; } } $ie = new COM("InternetExplorer.Application"); $sink =& new IEEventSinker(); com_event_sink($ie, $sink, "DWebBrowserEvents2"); $ie->Visible = true; $ie->Navigate("http://www.php.net"); while(!$sink->terminated) { com_message_pump(4000); } $ie = null; ?> ]]> </programlisting> </example> </para> </answer> </qandaentry> <qandaentry id="faq.com.q13"> <question> <para> I'm having problems when trying to invoke a method of a COM object which exposes more than one interface. What can I do ? </para> </question> <answer> <para> The answer is as simple as unsatisfying. I don't know exactly but i think you can do nothing. If someone has specific information about this, please let <ulink url="mailto:&email.harald;">me</ulink> know :) </para> </answer> </qandaentry> <qandaentry id="faq.com.q14"> <question> <para> So PHP works with COM, how about COM+ ? </para> </question> <answer> <para> COM+ extends COM by a framework for managing components through MTS and MSMQ but there is nothing special that PHP has to support to use such components. </para> </answer> </qandaentry> <qandaentry id="faq.com.q15"> <question> <para> If PHP can manipulate COM objects, can we imagine to use MTS to manage components resources, in conjunction with PHP ? </para> </question> <answer> <para> PHP itself doesn't handle transactions yet. Thus if an error occurs no rollback is initiated. If you use components that support transactions you will have to implement the transaction management yourself. </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/databases.xml +++ phpdoc-es/faq/databases.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.databases"> <title>Database issues</title> <titleabbrev>Database issues</titleabbrev> <para> This section holds common questions about relation between PHP and databases. Yes, PHP can access virtually any database available today. </para> <qandaset> <qandaentry id="faq.databases.mssql"> <question> <para> I heard it's possible to access Microsoft SQL Server from PHP. How? </para> </question> <answer> <para> On Windows machines, you can simply use the included ODBC support and the correct ODBC driver. </para> <para> On Unix machines, you can use the Sybase-CT driver to access Microsoft SQL Servers because they are (at least mostly) protocol-compatible. Sybase has made a <ulink url="&url.sybase.ctlib;">free version of the necessary libraries for Linux systems</ulink>. For other Unix operating systems, you need to contact Sybase for the correct libraries. Also see the answer to the next question. </para> </answer> </qandaentry> <qandaentry id="faq.databases.access"> <question> <para>Can I access Microsoft Access databases?</para> </question> <answer> <para> Yes. You already have all the tools you need if you are running entirely under Windows 9x/Me, or NT/2000, where you can use ODBC and Microsoft's ODBC drivers for Microsoft Access databases. </para> <para> If you are running PHP on a Unix box and want to talk to MS Access on a Windows box you will need Unix ODBC drivers. <ulink url="&url.openlink;">OpenLink Software</ulink> has Unix-based ODBC drivers that can do this. There is a free pilot program where you can download an evaluation copy that doesn't expire and prices start at $675 for the commercial supported version. </para> <para> Another alternative is to use an SQL server that has Windows ODBC drivers and use that to store the data, which you can then access from Microsoft Access (using ODBC) and PHP (using the built in drivers), or to use an intermediary file format that Access and PHP both understand, such as flat files or dBase databases. On this point Tim Hayes from OpenLink software writes: <programlisting> Using another database as an intermediary is not a good idea, when you can use ODBC from PHP straight to your database - i.e. with OpenLink's drivers. If you do need to use an intermediary file format, OpenLink have now released Virtuoso (a virtual database engine) for NT, Linux and other unix platforms. Please visit our <ulink url="&url.openlink;">website</ulink> for a free download. </programlisting> </para> <para> One option that has proven successful is to use MySQL and its MyODBC drivers on Windows and synchronizing the databases. Steve Lawrence writes: </para> <para> <itemizedlist> <listitem> <simpara> Install MySQL on your platform according to instructions with MySQL. Latest available from <ulink url="&url.mysql;">www.mysql.com</ulink> (get it from your mirror!). No special configuration required except when you set up a database, and configure the user account, you should put % in the host field, or the host name of the Windows computer you wish to access MySQL with. Make a note of your server name, username, and password. </simpara> </listitem> <listitem> <simpara> Download the MyODBC for Windows driver from the MySQL site. Latest release is myodbc-2_50_19-win95.zip (NT available too, as well as source code). Install it on your Windows machine. You can test the operation with the utilities included with this program. </simpara> </listitem> <listitem> <simpara> Create a user or system dsn in your ODBC administrator, located in the control panel. Make up a dsn name, enter your hostname, user name, password, port, etc for you MySQL database configured in step 1. </simpara> </listitem> <listitem> <simpara> Install Access with a full install, this makes sure you get the proper add-ins.. at the least you will need ODBC support and the linked table manager. </simpara> </listitem> <listitem> <simpara> Now the fun part! Create a new access database. In the table window right click and select Link Tables, or under the file menu option, select Get External Data and then Link Tables. When the file browser box comes up, select files of type: ODBC. Select System dsn and the name of your dsn created in step 3. Select the table to link, press OK, and presto! You can now open the table and add/delete/edit data on your MySQL server! You can also build queries, import/export tables to MySQL, build forms and reports, etc. </simpara> </listitem> </itemizedlist> </para> <para> Tips and Tricks: <itemizedlist> <listitem> <simpara> You can construct your tables in Access and export them to MySQL, then link them back in. That makes table creation quick. </simpara> </listitem> <listitem> <simpara> When creating tables in Access, you must have a primary key defined in order to have write access to the table in access. Make sure you create a primary key in MySQL before linking in access </simpara> </listitem> <listitem> <simpara> If you change a table in MySQL, you have to re-link it in Access. Go to tools>add-ins>linked table manager, cruise to your ODBC DSN, and select the table to re-link from there. you can also move your dsn source around there, just hit the always prompt for new location checkbox before pressing OK. </simpara> </listitem> </itemizedlist> </para> </answer> </qandaentry> <qandaentry id="faq.databases.upgraded"> <question> <para> I upgraded to PHP 4, and now mysql keeps telling me "Warning: MySQL: Unable to save result set in ...". What's up? </para> </question> <answer> <para> Most likely what has happened is, PHP 4 was compiled with the '--with-mysql' option, without specifying the path to MySQL. This means PHP is using its built-in MySQL client library. If your system is running applications, such as PHP 3 as a concurrent Apache module, or auth-mysql, that use other versions of MySQL clients, then there is a conflict between the two differing versions of those clients. </para> <para> Recompiling PHP 4, and adding the path to MySQL to the flag, '<link linkend="mysql.configure">--with-mysql=/your/path/to/mysql</link>' usually solves the problem. </para> </answer> </qandaentry> <qandaentry id="faq.databases.shared-mysql"> <question> <para> After installing shared MySQL support, Apache dumps core as soon as libphp4.so is loaded. Can this be fixed? </para> </question> <answer> <para> If your MySQL libs are linked against pthreads this will happen. Check using ldd. If they are, grab the MySQL tarball and compile from source, or recompile from the source rpm and remove the switch in the spec file that turns on the threaded client code. Either of these suggestions will fix this. Then recompile PHP with the new MySQL libs. </para> </answer> </qandaentry> <qandaentry id="faq.databases.mysqlresource"> <question> <para> Why do I get an error that looks something like this: "Warning: 0 is not a MySQL result index in <file> on line <x>" or "Warning: Supplied argument is not a valid MySQL result resource in <file> on line <x>? </para> </question> <answer> <para> You are trying to use a result identifier that is 0. The 0 indicates that your query failed for some reason. You need to check for errors after submitting a query and before you attempt to use the returned result identifier. The proper way to do this is with code similar to the following: <programlisting role="php"> $result = mysql_query("SELECT * FROM tables_priv"); if (!$result) { echo mysql_error(); exit; } </programlisting> or <programlisting role="php"> $result = mysql_query("SELECT * FROM tables_priv") or die("Bad query: ".mysql_error()); </programlisting> </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/general.xml +++ phpdoc-es/faq/general.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.general"> <title>General Information</title> <titleabbrev>General Information</titleabbrev> <para> This section holds the most general questions about PHP: what it is and what it does. </para> <qandaset> <qandaentry id="faq.general.what"> <question> <para>What is PHP?</para> </question> <answer> <para> From the <link linkend="preface">preface of the manual</link>: </para> <para> PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly. </para> <para> A nice introduction to PHP by Stig Sæther Bakken can be found <ulink url="&url.zend.introduction;">here</ulink> on the Zend website. Also, much of the <ulink url="&url.php.conf;">PHP Conference Material</ulink> is freely available. </para> </answer> </qandaentry> <qandaentry id="faq.general.acronym"> <question> <para>What does PHP stand for?</para> </question> <answer> <para> PHP stands for <emphasis>PHP: Hypertext Preprocessor</emphasis>. This confuses many people because the first word of the acronym is the acronym. This type of acronym is called a recursive acronym. The curious can visit <ulink url="&url.foldoc;">Free On-Line Dictionary of Computing</ulink> for more information on recursive acronyms. </para> </answer> </qandaentry> <qandaentry id="faq.general.relation-versions"> <question> <para>What is the relation between the versions?</para> </question> <answer> <para> PHP/FI 2.0 is an early and no longer supported version of PHP. PHP 3 is the successor to PHP/FI 2.0 and is a lot nicer. PHP 4 is the current generation of PHP, which uses the <ulink url="&url.zend;">Zend engine</ulink> under the hood. PHP 5 uses <ulink url="&url.zend.future;">Zend engine 2</ulink> which, among other things, offers many additional <link linkend="ref.classobj">OOP</link> features. PHP 5 is experimental. </para> </answer> </qandaentry> <qandaentry id="faq.general.running-concurent"> <question> <para>Can I run several versions of PHP at the same time?</para> </question> <answer> <para> Yes. See the <filename>INSTALL</filename> file that is included in the PHP 4 source distribution. Also, read the related <link linkend="migration4.php4.with.php3">appendix</link>. </para> </answer> </qandaentry> <qandaentry id="faq.general.differences-34"> <question> <para>What are the differences between PHP 3 and PHP 4?</para> </question> <answer> <para> There are <ulink url="&url.zend.articles;">a couple of articles</ulink> written on this by the authors of PHP 4. Here's a list of some of the more important new features: <itemizedlist> <listitem> <simpara>Extended API module</simpara> </listitem> <listitem> <simpara>Generalized build process under UNIX</simpara> </listitem> <listitem> <simpara>Generic web server interface that also supports multi-threaded web servers</simpara> </listitem> <listitem> <simpara>Improved syntax highlighter</simpara> </listitem> <listitem> <simpara>Native HTTP session support</simpara> </listitem> <listitem> <simpara>Output buffering support</simpara> </listitem> <listitem> <simpara>More powerful configuration system</simpara> </listitem> <listitem> <simpara>Reference counting</simpara> </listitem> </itemizedlist> Please see the <ulink url="&url.zend.new;">What's new in PHP 4 overview</ulink> for a detailed explanation of these features and more. If you're migrating from PHP 3 to PHP 4, also read the related <link linkend="migration4">appendix</link>. </para> </answer> </qandaentry> <qandaentry id="faq.general.bug"> <question> <para> I think I found a bug! Who should I tell? </para> </question> <answer> <para> You should go to the PHP Bug Database and make sure the bug isn't a known bug. If you don't see it in the database, use the reporting form to report the bug. It is important to use the bug database instead of just sending an email to one of the mailing lists because the bug will have a tracking number assigned and it will then be possible for you to go back later and check on the status of the bug. The bug database can be found at <ulink url="&url.php.bugs;">&url.php.bugs;</ulink>. </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/html.xml +++ phpdoc-es/faq/html.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.html"> <title>PHP and HTML</title> <titleabbrev>PHP and HTML</titleabbrev> <para> PHP and HTML interact a lot: PHP can generate HTML, and HTML can pass information to PHP. Before reading these faqs, it's important you learn how to <link linkend="language.variables.external"> retrieve variables from outside of PHP</link>. The manual page on this topic includes many examples as well. Pay close attention to what <literal>register_globals</literal> means to you too. </para> <qandaset> <qandaentry id="faq.html.encoding"> <question> <para> What encoding/decoding do I need when I pass a value through a form/URL? </para> </question> <answer> <para> There are several stages for which encoding is important. Assuming that you have a <type>string</type> <varname>$data</varname>, which contains the string you want to pass on in a non-encoded way, these are the relevant stages: <itemizedlist> <listitem> <para> HTML interpretation. In order to specify a random string, you <emphasis>must</emphasis> include it in double quotes, and <function>htmlspecialchars</function> the whole value. </para> </listitem> <listitem> <para> URL: A URL consists of several parts. If you want your data to be interpreted as one item, you <emphasis>must</emphasis> encode it with <function>urlencode</function>. </para> </listitem> </itemizedlist> </para> <para> <example> <title>A hidden HTML form element</title> <programlisting role="php"> <![CDATA[ <?php echo "<input type=hidden value=\"" . htmlspecialchars($data) . "\">\n"; ?> ]]> </programlisting> </example> <note> <simpara> It is wrong to <function>urlencode</function> <varname>$data</varname>, because it's the browsers responsibility to <function>urlencode</function> the data. All popular browsers do that correctly. Note that this will happen regardless of the method (i.e., GET or POST). You'll only notice this in case of GET request though, because POST requests are usually hidden. </simpara> </note> <example> <title>Data to be edited by the user</title> <programlisting role="php"> <![CDATA[ <?php echo "<textarea name=mydata>\n"; echo htmlspecialchars($data)."\n"; echo "</textarea>"; ?> ]]> </programlisting> </example> <note> <simpara> The data is shown in the browser as intended, because the browser will interpret the HTML escaped symbols. </simpara> <simpara> Upon submitting, either via GET or POST, the data will be urlencoded by the browser for transferring, and directly urldecoded by PHP. So in the end, you don't need to do any urlencoding/urldecoding yourself, everything is handled automagically. </simpara> </note> <example> <title>In an URL</title> <programlisting role="php"> <![CDATA[ <?php echo "<a href=\"" . htmlspecialchars("/nextpage.php?stage=23&data=" . urlencode($data)) . "\">\n"; ?> ]]> </programlisting> </example> <note> <simpara> In fact you are faking a HTML GET request, therefore it's necessary to manually <function>urlencode</function> the data. </simpara> </note> <note> <simpara> You need to <function>htmlspecialchars</function> the whole URL, because the URL occurs as value of an HTML-attribute. In this case, the browser will first un-<function>htmlspecialchars</function> the value, and then pass the URL on. PHP will understand the URL correctly, because you <function>urlencoded</function> the data. </simpara> <simpara> You'll notice that the <literal>&</literal> in the URL is replaced by <literal>&amp;</literal>. Although most browsers will recover if you forget this, this isn't always possible. So even if your URL is not dynamic, you <emphasis>need</emphasis> to <function>htmlspecialchars</function> the URL. </simpara> </note> </para> <!-- TODO: a note about addgpcslashes? --> </answer> </qandaentry> <qandaentry id="faq.html.form-image"> <question> <para> I'm trying to use an <input type="image"> tag, but the <varname>$foo.x</varname> and <varname>$foo.y</varname> variables aren't available. <varname>$_GET['foo.x']</varname> isn't existing either. Where are they? </para> </question> <answer> <para> When submitting a form, it is possible to use an image instead of the standard submit button with a tag like: <programlisting role="html"> <![CDATA[ <input type="image" src="image.gif" name="foo"> ]]> </programlisting> When the user clicks somewhere on the image, the accompanying form will be transmitted to the server with two additional variables: <varname>foo.x</varname> and <varname>foo.y</varname>. </para> <para> Because <varname>foo.x</varname> and <varname>foo.y</varname> would make invalid variable names in PHP, they are automagically converted to <varname>foo_x</varname> and <varname>foo_y</varname>. That is, the periods are replaced with underscores. So, you'd access these variables like any other described within the section on retrieving <link linkend="language.variables.external">variables from outside of PHP</link>. For example, <varname>$_GET['foo_x']</varname>. </para> </answer> </qandaentry> <qandaentry id="faq.html.arrays"> <question> <para>How do I create arrays in a HTML <form>?</para> </question> <answer> <para> To get your <form> result sent as an <link linkend="language.types.array">array</link> to your PHP script you name the <input>, <select> or <textarea> elements like this: <programlisting role="html"> <![CDATA[ <input name="MyArray[]"> <input name="MyArray[]"> <input name="MyArray[]"> <input name="MyArray[]"> ]]> </programlisting> Notice the square brackets after the variable name, that's what makes it an array. You can group the elements into different arrays by assigning the same name to different elements: <programlisting role="html"> <![CDATA[ <input name="MyArray[]"> <input name="MyArray[]"> <input name="MyOtherArray[]"> <input name="MyOtherArray[]"> ]]> </programlisting> This produces two arrays, MyArray and MyOtherArray, that gets sent to the PHP script. It's also possible to assign specific keys to your arrays: <programlisting role="html"> <![CDATA[ <input name="AnotherArray[]"> <input name="AnotherArray[]"> <input name="AnotherArray[email]"> <input name="AnotherArray[phone]"> ]]> </programlisting> The AnotherArray array will now contain the keys 0, 1, email and phone. </para> <para> <note> <para> Specifying an arrays key is optional in HTML. If you do not specify the keys, the array gets filled in the order the elements appear in the form. Our first example will contain keys 0, 1, 2 and 3. </para> </note> </para> <para> See also <link linkend="ref.array">Array Functions</link> and <link linkend="language.variables.external">Variables from outside PHP</link>. </para> </answer> </qandaentry> <qandaentry id="faq.html.select-multiple"> <question> <para> How do I get all the results from a select multiple HTML tag? </para> </question> <answer> <para> The select multiple tag in an HTML construct allows users to select multiple items from a list. These items are then passed to the action handler for the form. The problem is that they are all passed with the same widget name. ie. <programlisting role="html"> <![CDATA[ <select name="var" multiple> ]]> </programlisting> Each selected option will arrive at the action handler as: <programlisting> var=option1 var=option2 var=option3 </programlisting> Each option will overwrite the contents of the previous <varname>$var</varname> variable. The solution is to use PHP's "array from form element" feature. The following should be used: <programlisting role="html"> <![CDATA[ <select name="var[]" multiple> ]]> </programlisting> This tells PHP to treat <varname>$var</varname> as an array and each assignment of a value to var[] adds an item to the array. The first item becomes <varname>$var[0]</varname>, the next <varname>$var[1]</varname>, etc. The <function>count</function> function can be used to determine how many options were selected, and the <function>sort</function> function can be used to sort the option array if necessary. </para> <para> Note that if you are using JavaScript the <literal>[]</literal> on the element name might cause you problems when you try to refer to the element by name. Use it's numerical form element ID instead, or enclose the variable name in single quotes and use that as the index to the elements array, for example: <programlisting> variable = documents.forms[0].elements['var[]']; </programlisting> </para> </answer> </qandaentry> <qandaentry id="faq.html.javascript-variable"> <question> <para> How can I pass a variable from Javascript to PHP? </para> </question> <answer> <para> Since Javascript is (usually) a client-side technology, and PHP is (usually) a server-side technology, and since HTTP is a "stateless" protocol, the two languages cannot directly share variables. </para> <para> It is, however, possible to pass variables between the two. One way of accomplishing this is to generate Javascript code with PHP, and have the browser refresh itself, passing specific variables back to the PHP script. The example below shows precisely how to do this -- it allows PHP code to capture screen height and width, something that is normally only possible on the client side. </para> <para> <programlisting> <![CDATA[ <?php if (isset($_GET['width']) AND isset($_GET['height'])) { // output the geometry variables echo "Screen width is: ". $_GET['width'] ."<br />\n"; echo "Screen height is: ". $_GET['height'] ."<br />\n"; } else { // pass the geometry variables // (preserve the original query string // -- post variables will need to handled differently) echo "<script language=\"javascript\">\n"; echo " location.href=\"${_SERVER['SCRIPT_NAME']}?${_SERVER['QUERY_STRING']}" . "&width=\" + screen.width + \"&height=\" + screen.height;\n"; echo "</script>\n"; exit(); } ?> ]]> </programlisting> </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/installation.xml +++ phpdoc-es/faq/installation.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.installation"> <title>Installation</title> <titleabbrev>Installation</titleabbrev> <para> This section holds common questions about the way to install PHP. PHP is available for almost any OS (except maybe for MacOS before OSX), and almost any web server. </para> <para> To install PHP, follow the instructions in the <ulink url="&url.file.installation;">INSTALL</ulink> file located in the distribution. Windows users should also read the <ulink url="&url.file.readmewin;">install.txt</ulink> file. There are also some helpful hints for Windows users <link linkend="install.windows">here</link>. </para> <qandaset> <qandaentry id="faq.installation.phpini"> <question> <para> Unix/Windows: Where should my &php.ini; file be located? </para> </question> <answer> <para> By default on UNIX it should be in <filename>/usr/local/lib</filename> which is <filename><install-path>/lib</filename>. Most people will want to change this at compile-time with the <link linkend="install.configure.with-config-file-path">--with-config-file-path</link> flag. You would, for example, set it with something like: <programlisting> --with-config-file-path=/etc </programlisting> And then you would copy <filename>php.ini-dist</filename> from the distribution to <filename>/etc/php.ini</filename> and edit it to make any local changes you want. </para> <programlisting> --with-config-file-scan-dir=PATH </programlisting> <para> On Windows the default path for the &php.ini; file is the Windows directory. If you're using the Apache webserver, &php.ini; is first searched in the Apaches install directory, e.g. <filename>c:\program files\apache group\apache</filename>. This way you can have different &php.ini; files for different versions of Apache on the same machine. </para> <para> See also the chapter about the <link linkend="configuration.file">configuration file</link>. </para> </answer> </qandaentry> <qandaentry id="faq.installation.nodata"> <question> <para> Unix: I installed PHP, but every time I load a document, I get the message 'Document Contains No Data'! What's going on here? </para> </question> <answer> <para> This probably means that PHP is having some sort of problem and is core-dumping. Look in your server error log to see if this is the case, and then try to reproduce the problem with a small test case. If you know how to use 'gdb', it is very helpful when you can provide a backtrace with your bug report to help the developers pinpoint the problem. If you are using PHP as an Apache module try something like: <itemizedlist> <listitem> <para> Stop your httpd processes </para> </listitem> <listitem> <para> gdb httpd </para> </listitem> <listitem> <para> Stop your httpd processes </para> </listitem> <listitem> <para> > run -X -f /path/to/httpd.conf </para> </listitem> <listitem> <para> Then fetch the URL causing the problem with your browser </para> </listitem> <listitem> <para> > run -X -f /path/to/httpd.conf </para> </listitem> <listitem> <para> If you are getting a core dump, gdb should inform you of this now </para> </listitem> <listitem> <para> type: bt </para> </listitem> <listitem> <para> You should include your backtrace in your bug report. This should be submitted to <ulink url="&url.php.bugs;">&url.php.bugs;</ulink> </para> </listitem> </itemizedlist> </para> <para> If your script uses the regular expression functions (<function>ereg</function> and friends), you should make sure that you compiled PHP and Apache with the same regular expression package. This should happen automatically with PHP and Apache 1.3.x </para> </answer> </qandaentry> <qandaentry id="faq.installation.processing"> <question> <para> Unix: I installed PHP using RPMS, but Apache isn't processing the PHP pages! What's going on here? </para> </question> <answer> <para> Assuming you installed both Apache and PHP from RPM packages, you need to uncomment or add some or all of the following lines in your &httpd.conf; file: <programlisting> # Extra Modules AddModule mod_php.c AddModule mod_php3.c AddModule mod_perl.c # Extra Modules LoadModule php_module modules/mod_php.so LoadModule php3_module modules/libphp3.so /* for PHP 3 */ LoadModule php4_module modules/libphp4.so /* for PHP 4 */ LoadModule perl_module modules/libperl.so </programlisting> And add: <programlisting> AddType application/x-httpd-php3 .php3 /* for PHP 3 */ AddType application/x-httpd-php .php /* for PHP 4 */ </programlisting> ... to the global properties, or to the properties of the VirtualDomain you want to have PHP support added to. </para> </answer> </qandaentry> <qandaentry id="faq.installation.compile"> <question> <para> Unix: I installed PHP 3 using RPMS, but it doesn't compile with the database support I need! What's going on here? </para> </question> <answer> <para> Due to the way PHP 3 built, it is not easy to build a complete flexible PHP RPM. This issue is addressed in PHP 4. For PHP 3, we currently suggest you use the mechanism described in the INSTALL.REDHAT file in the PHP distribution. If you insist on using an RPM version of PHP 3, read on... </para> <para> The RPM packagers are setting up the RPMS to install without database support to simplify installations <emphasis>and</emphasis> because RPMS use /usr/ instead of the standard /usr/local/ directory for files. You need to tell the RPM spec file which databases to support and the location of the top-level of your database server. </para> <para> This example will explain the process of adding support for the popular MySQL database server, using the mod installation for Apache. </para> <para> Of course all of this information can be adjusted for any database server that PHP supports. We will assume you installed MySQL and Apache completely with RPMS for this example as well. <itemizedlist> <listitem> <para> First remove mod_php3 : <programlisting> rpm -e mod_php3 </programlisting> </para> </listitem> <listitem> <para> Then get the source rpm and INSTALL it, NOT --rebuild <programlisting> rpm -Uvh mod_php3-3.0.5-2.src.rpm </programlisting> </para> </listitem> <listitem> <para> Then edit the <filename>/usr/src/redhat/SPECS/mod_php3.spec</filename> file </para> <para> In the %build section add the database support you want, and the path. </para> <para> For MySQL you would add <programlisting> --with-mysql=/usr \ </programlisting> The %build section will look something like this: <programlisting> ./configure --prefix=/usr \ --with-apxs=/usr/sbin/apxs \ --with-config-file-path=/usr/lib \ --enable-debug=no \ --enable-safe-mode \ --with-exec-dir=/usr/bin \ --with-mysql=/usr \ --with-system-regex </programlisting> </para> </listitem> <listitem> <para> Once this modification is made then build the binary rpm as follows: <programlisting> rpm -bb /usr/src/redhat/SPECS/mod_php3.spec </programlisting> </para> </listitem> <listitem> <para> Then install the rpm <programlisting> rpm -ivh /usr/src/redhat/RPMS/i386/mod_php3-3.0.5-2.i386.rpm </programlisting> </para> </listitem> </itemizedlist> Make sure you restart Apache, and you now have PHP 3 with MySQL support using RPM's. Note that it is probably much easier to just build from the distribution tarball of PHP 3 and follow the instructions in <filename>INSTALL.REDHAT</filename> found in that distribution. </para> </answer> </qandaentry> <qandaentry id="faq.installation.frontpage"> <question> <para> Unix: I patched Apache with the FrontPage extensions patch, and suddenly PHP stopped working. Is PHP incompatible with the Apache FrontPage extensions? </para> </question> <answer> <para> No, PHP works fine with the FrontPage extensions. The problem is that the FrontPage patch modifies several Apache structures, that PHP relies on. Recompiling PHP (using 'make clean ; make') after the FP patch is applied would solve the problem. </para> </answer> </qandaentry> <qandaentry id="faq.installation.blankscreen"> <question> <para> Unix/Windows: I have installed PHP, but when I try to access a PHP script file via my browser, I get a blank screen. </para> </question> <answer> <para> Do a 'view source' in the web browser and you will probably find that you can see the source code of your PHP script. This means that the web server did not send the script to PHP for interpretation. Something is wrong with the server configuration - double check the server configuration against the PHP installation instructions. </para> </answer> </qandaentry> <qandaentry id="faq.installation.500error"> <question> <para> Unix/Windows: I have installed PHP, but when try to access a PHP script file via my browser, I get a server 500 error. </para> </question> <answer> <para> Something went wrong when the server tried to run PHP. To get to see a sensible error message, from the command line, change to the directory containing the PHP executable (<filename>php.exe</filename> on Windows) and run <literal>php -i</literal>. If PHP has any problems running, then a suitable error message will be displayed which will give you a clue as to what needs to be done next. If you get a screen full of html codes (the output of the <function>phpinfo</function> function) then PHP is working, and your problem may be related to your server configuration which you should double check. </para> </answer> </qandaentry> <qandaentry id="faq.installation.undefinedsyms"> <question> <para> Some operating systems: I have installed PHP without errors, but when I try to start apache I get undefined symbol errors: <programlisting> [mybox:user /src/php4] root# apachectl configtest apachectl: /usr/local/apache/bin/httpd Undefined symbols: _compress _uncompress </programlisting> </para> </question> <answer> <para> This has actually nothing to do with PHP, but with the MySQL client libraries. Some need --with-zlib, others do not. This is also covered in the MySQL FAQ. </para> </answer> </qandaentry> <qandaentry id="faq.installation.cgierror"> <question> <para> Windows: I have installed PHP, but when I to access a PHP script file via my browser, I get the error: <programlisting> cgi error: The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are: </programlisting> </para> </question> <answer> <para> This error message means that PHP failed to output anything at all. To get to see a sensible error message, from the command line, change to the directory containing the PHP executable (<filename>php.exe</filename> on Windows) and run <literal>php -i</literal>. If PHP has any problems running, then a suitable error message will be displayed which will give you a clue as to what needs to be done next. If you get a screen full of html codes (the output of the <function>phpinfo</function> function) then PHP is working. </para> <para> Once PHP is working at the command line, try accessing the script via the browser again. If it still fails then it could be one of the following: </para> <itemizedlist> <listitem> <simpara> File permissions on your PHP script, <filename>php.exe</filename>, <filename>php4ts.dll</filename>, &php.ini; or any PHP extensions you are trying to load are such that the anonymous internet user <literal>ISUR_<machinename></literal> cannot access them. </simpara> </listitem> <listitem> <simpara> The script file does not exist (or possibly isn't where you think it is relative to your web root directory). Note that for IIS you can trap this error by ticking the 'check file exists' box when setting up the script mappings in the Internet Services Manager. If a script file does not exist then the server will return a 404 error instead. There is also the additional benefit that IIS will do any authentication required for you based on the NTLanMan permissions on your script file. </simpara> </listitem> </itemizedlist> </answer> </qandaentry> <qandaentry id="faq.installation.phpandiis"> <question> <para> Windows: I've followed all the instructions, but still can't get PHP and IIS to work together! </para> </question> <answer> <para> Make sure any user who needs to run a PHP script has the rights to run <filename>php.exe</filename>! IIS uses an anonymous user which is added at the time IIS is installed. This user needs rights to <filename>php.exe</filename>. Also, any authenticated user will also need rights to execute <filename>php.exe</filename>. And for IIS4 you need to tell it that PHP is a script engine. Also, you will want to read <link linkend="faq.installation.forceredirect">this faq</link>. </para> </answer> </qandaentry> <qandaentry id="faq.installation.forceredirect"> <question> <para> When running PHP as CGI with IIS, PWS, OmniHTTPD or Xitami, I get the following error: <literal>Security Alert! PHP CGI cannot be accessed directly.</literal>. </para> </question> <answer> <para> You must set the <link linkend="ini.cgi.force-redirect"> cgi.force_redirect</link> directive to <literal>0</literal>. It defaults to <literal>1</literal> so be sure the directive isn't commented out (with a <literal>;</literal>). Like all directives, this is set in &php.ini; </para> <para> Because the default is <literal>1</literal>, it's critical that you're 100% sure that the correct &php.ini; file is being read. Read <link linkend="faq.installation.findphpini">this faq</link> for details. </para> </answer> </qandaentry> <qandaentry id="faq.installation.findphpini"> <question> <para> How do I know if my &php.ini; is being found and read? It seems like it isn't as my changes aren't being implemented. </para> </question> <answer> <para> To be sure your &php.ini; is being read by PHP, make a call to <function>phpinfo</function> and near the top will be a listing called <literal>Configuration File (php.ini)</literal>. This will tell you where PHP is looking for &php.ini; and whether or not it's being read. If just a directory PATH exists than it's not being read and you should put your &php.ini; in that directory. If &php.ini; is included within the PATH than it is being read. </para> <para> If &php.ini; is being read and you're running PHP as a module then be sure to restart PHP after making changes to &php.ini; </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/languages.xml +++ phpdoc-es/faq/languages.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.languages"> <title>PHP and other languages</title> <titleabbrev>PHP and other languages</titleabbrev> <para> PHP is the best language for web programing, but what about other languages? </para> <qandaset> <qandaentry id="faq.languages.asp"> <question> <para>PHP vs. ASP?</para> </question> <answer> <para> ASP is not really a language in itself, it's an acronym for Active Server Pages, the actual language used to program ASP with is Visual Basic Script or JScript. The biggest drawback of ASP is that it's a proprietary system that is natively used only on Microsoft Internet Information Server (IIS). This limits it's availability to Win32 based servers. There are a couple of projects in the works that allows ASP to run in other environments and webservers: <ulink url="&url.instantasp;">InstantASP</ulink> from <ulink url="&url.halcyon;">Halcyon</ulink> (commercial), <ulink url="&url.chilisoft.asp;">Chili!Soft ASP</ulink> from <ulink url="&url.chilisoft;">Chili!Soft</ulink> (commercial) and <ulink url="&url.openasp;">OpenASP from ActiveScripting.org</ulink> (free). ASP is said to be a slower and more cumbersome language than PHP, less stable as well. Some of the pros of ASP is that since it primarily uses VBScript it's relatively easy to pick up the language if you're already know how to program in Visual Basic. ASP support is also enabled by default in the IIS server making it easy to get up and running. The components built in ASP are really limited, so if you need to use "advanced" features like interacting with FTP servers, you need to buy additional components. </para> </answer> </qandaentry> <qandaentry id="faq.languages.aspconverter"> <question> <para>Is there an ASP to PHP converter?</para> </question> <answer> <para> Yes, the server-side <ulink url="&url.asp2php;">asp2php</ulink> is the one most often referred to as well as <ulink url="&url.asptranslator;">this client-side</ulink> option. </para> </answer> </qandaentry> <qandaentry id="faq.languages.coldfusion"> <question> <para>PHP vs. Cold Fusion?</para> </question> <answer> <para> PHP is commonly said to be faster and more efficient for complex programming tasks and trying out new ideas. PHP is generally referred to as more stable and less resource intensive as well. Cold Fusion has better error handling, database abstraction and date parsing although database abstraction is addressed in PHP 4. Another thing that is listed as one of Cold Fusion's strengths is its excellent search engine, but it has been mentioned that a search engine is not something that should be included in a web scripting language. PHP runs on almost every platform there is; Cold Fusion is only available on Win32, Solaris, Linux and HP/UX. Cold Fusion has a good IDE and is generally easier to get started with, whereas PHP initially requires more programming knowledge. Cold Fusion is designed with non-programmers in mind, while PHP is focused on programmers. </para> <para> A great summary by Michael J Sheldon on this topic has been posted to the PHP mailing list. A copy can be found <ulink url="&url.coldfusion.summary;">here</ulink>. </para> </answer> </qandaentry> <qandaentry id="faq.languages.perl"> <question> <para>PHP vs. Perl?</para> </question> <answer> <para> The biggest advantage of PHP over Perl is that PHP was designed for scripting for the web where Perl was designed to do a lot more and can because of this get very complicated. The flexibility / complexity of Perl makes it easier to write code that another author / coder has a hard time reading. PHP has a less confusing and stricter format without losing flexibility. PHP is easier to integrate into existing HTML than Perl. PHP has pretty much all the 'good' functionality of Perl: constructs, syntax and so on, without making it as complicated as Perl can be. Perl is a very tried and true language, it's been around since the late eighties, but PHP is maturing very quickly. </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/mailinglist.xml +++ phpdoc-es/faq/mailinglist.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.mailinglist"> <title>Mailing lists</title> <titleabbrev>Mailing lists</titleabbrev> <para> This section holds questions about how to get in touch with the PHP community. The best way is the mailing lists. </para> <qandaset> <qandaentry id="faq.mailinglist.isthere"> <question> <para>Are there any PHP mailing lists?</para> </question> <answer> <para> Of course! There are many mailing lists for several subjects. A whole list of mailing lists can be found on our <ulink url="&url.php.support;">Support</ulink> page. </para> <para> The most general mailing list is <literal>php-general</literal>. To subscribe, send mail to <ulink url="mailto:&url.ml.general.subscribe;">&url.ml.general.subscribe;</ulink>. You don't need to include anything special in the subject or body of the message. To unsubscribe, send mail to <ulink url="mailto:&url.ml.general.unsubscribe;">&url.ml.general.unsubscribe;</ulink>. </para> <para> You can also subscribe and unsubscribe using the web interface on our <ulink url="&url.php.support;">Support</ulink> page. </para> </answer> </qandaentry> <qandaentry id="faq.mailinglist.others"> <question> <para>Are there any other communities?</para> </question> <answer> <para> There are countless of them around the world. We have links for example to some IRC servers and foreign language mailing lists on our <ulink url="&url.php.support;">Support</ulink> page. </para> </answer> </qandaentry> <qandaentry id="faq.mailinglist.subscribing"> <question> <para> Help! I can't seem to subscribe/unsubscribe to/from one of the mailing lists! </para> </question> <answer> <para> If you have problems subscribing to or unsubscribing from the php-general mailing list, it may be because the mailing list software can't figure out the correct mailing address to use. If your email address was <literal>joeblow@example.com</literal>, you can send your subscription request to <literal>php-general-subscribe-joeblow=example.com@lists.php.net</literal>, or your unsubscription request to <literal>php-general-unsubscribe-joeblow=example.com@lists.php.net</literal>. Use similar addresses for the other mailing lists. </para> </answer> </qandaentry> <qandaentry id="faq.mailinglist.archive"> <question> <para>Is there an archive of the mailing lists anywhere?</para> </question> <answer> <para> Yes, you will find a list of archive sites on the <ulink url="&url.php.support;">Support</ulink> page. The mailing list articles are also archived as news messages. You can access the news server at <ulink url="&url.php.news;">&url.php.news;</ulink> with a news client. There is also an experimental web interface for the news server at <ulink url="&url.php.newsweb;">&url.php.newsweb;</ulink> </para> </answer> </qandaentry> <qandaentry id="faq.mailinglist.question"> <question> <para>What can I ask the mailing list?</para> </question> <answer> <para> Since PHP is growing more and more popular by the day the traffic has increased on the php-general mailing list and as of now the list gets about 150 to 200 posts a day. Because of this it is in everyones interest that you use the list as a last resort when you have looked everywhere else. </para> <para> Before you post to the list please have a look in this FAQ and the manual to see if you can find the help there. If there is nothing to be found there try out the mailing list archives (see above). If you're having problem with installing or configuring PHP please read through all included documentation and README's. If you still can't find any information that helps you out you're more than welcome to use the mailing list. </para> <para> Before asking questions, you may want to read the paper on <ulink url="&url.smart.questions;">How To Ask Questions The Smart Way</ulink> as this is a good idea for everyone. </para> </answer> </qandaentry> <qandaentry id="faq.mailinglist.guideline"> <question> <para>What information should I include when posting to the mailing list?</para> </question> <answer> <para> Posts like "I can't get PHP up and running! Help me! What is wrong?" are of absolutely no use to anyone. If you're having problems getting PHP up and running you must include what operating system you are running on, what version of PHP you're trying to set up, how you got it (pre-compiled, CVS, RPMs and so on), what you have done so far, where you got stuck and the exact error message. </para> <para> This goes for any other problem as well. You have to include information on what you have done, where you got stuck, what you're trying to do and, if applicable, exact error messages. If you're having problems with your source code you need to include the part of the code that isn't working. Do not include more code than necessary though! It makes the post hard to read and a lot of people might just skip it all together because of this. If you're unsure about how much information to include in the mail it's better that you include to much than to little. </para> <para> Another important thing to remember is to summarize your problem on the subject line. A subject like "HELP MEEEE!!!" or "What is the problem here?" will be ignored by the majority of the readers. </para> <para> And lastly, you're encouraged to read the paper on <ulink url="&url.smart.questions;">How To Ask Questions The Smart Way</ulink> as this will be a great help for everyone, especially yourself. </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/migration.xml +++ phpdoc-es/faq/migration.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.migration"> <title>Migrating from PHP 2 to PHP 3</title> <titleabbrev>Migrating from PHP 2 to PHP 3</titleabbrev> <para> PHP has already a long history behind him: Legendary PHP 1.0, PHP/FI, PHP 3.0 and PHP 4.0. </para> <qandaset> <qandaentry id="faq.migrating.phpfi"> <question> <para> Migrating from PHP 2 to PHP 3? </para> </question> <answer> <para> PHP/FI 2.0 is no longer supported. Please see <link linkend="migration">appropriate manual section</link> for information about migration from PHP/FI 2.0. </para> <para> If you are still working with PHP 2, we <emphasis>strongly</emphasis> recommend you to upgrade straight to PHP 4. </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/migration4.xml +++ phpdoc-es/faq/migration4.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.migration4"> <title>Migrating from PHP 3 to PHP 4</title> <titleabbrev>Migrating from PHP 3 to PHP 4</titleabbrev> <para> PHP has already a long history behind him : Legendary PHP 1.0, PHP/FI, PHP 3.0 and PHP 4.0. </para> <qandaset> <qandaentry id="faq.migration4.php34"> <question> <para> Migrating from PHP3 to PHP4 </para> </question> <answer> <para> PHP 4 was designed to be as compatible with earlier versions of PHP as possible and very little functionality was broken in the process. If you're really unsure about compatibility you should install PHP 4 in a test environment and run your scripts there. </para> <para> Also see the <link linkend="migration4">appropriate migration appendix</link> of this manual. </para> </answer> </qandaentry> <qandaentry id="faq.migration4.sessions"> <question> <para> Do sessions work in PHP 3? </para> </question> <answer> <para> Although <link linkend="ref.session">native session support</link> didn't exist in PHP 3, there are third-party applications that did (and still do) offer session functionality. The most common method was by using <ulink url="&url.phplib;">PHPLIB</ulink>. </para> </answer> </qandaentry> <qandaentry id="faq.migration4.incompatible"> <question> <para> Incompatible functions? </para> </question> <answer> <para> Since PHP 4 is basically a rewrite of the entire PHP engine there was very few functions that were altered and only then some of the more exotic ones. </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/misc.xml +++ phpdoc-es/faq/misc.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.misc"> <title>Miscellaneous Questions</title> <titleabbrev>Miscellaneous Questions</titleabbrev> <para> There can be some questions we can't put into other categories. Here you can find them. </para> <qandaset> <qandaentry id="faq.misc.popup"> <question> <para> Where did the pop-ups go on the website? Can I have the code for that? </para> </question> <answer> <para> The yellow pop-up windows on the old site were pretty cool, but were very difficult to maintain (since some companies seem to enjoy changing the way their browsers work with every new release). </para> <para> All the code for previous versions of the website is still available through CVS. Specifically, the last version of shared.inc (that had all the Javascript and DHTML to do the popups) is available <ulink url="&url.popup;">here</ulink>. </para> </answer> </qandaentry> <qandaentry id="faq.misc.bz2"> <question> <para> How can I handle the bz2 compressed manuals on Windows? </para> </question> <answer> <para> If you don't have an archiver-tool to handle bz2 files <ulink url="&url.bzip2;">download</ulink> the commandline tool from Redhat (please find further information below). </para> <para> If you would not like to use a command line tool, you can try free tools like <ulink url="&url.stuffit;">Stuffit Expander</ulink>, <ulink url="&url.ultimatezip;">UltimateZip</ulink>, <ulink url="&url.7zip;">7-Zip</ulink>, or <ulink url="&url.quickzip;">Quick Zip</ulink>. If you have tools like <ulink url="&url.winrar;">WinRAR</ulink> or <ulink url="&url.powerarchiver;">Power Archiver</ulink>, you can easily decompress the bz2 files with it. If you use Windows Commander, a bz2 plugin for that program is available freely from the <ulink url="&url.wincmd;">Windows Commander</ulink> site. </para> <para> The bzip2 commandline tool from Redhat: </para> <para> Win2k Sp2 users grab the latest version 1.0.2, all other Windows user should grab version 1.00. After downloading rename the executable to bzip2.exe. For convenience put it into a directory in your path, e.g. C:\Windows where C represents your windows installation drive. </para> <para> Note: lang stands for your language and x for the desired format, e.g.: pdf. To uncompress the php_manual_lang.x.bz2 follow these simple instructions: <itemizedlist> <listitem> <simpara>open a command prompt window</simpara> </listitem> <listitem> <simpara> cd to the folder where you stored the downloaded php_manual_lang.x.bz2 </simpara> </listitem> <listitem> <simpara> invoke bzip2 -d php_manual_lang.x.bz2, extracting php_manual_lang.x in the same folder </simpara> </listitem> </itemizedlist> </para> <para> In case you downloaded the php_manual_lang.tar.bz2 with many html-files in it, the procedure is the same. The only difference is that you got a file php_manual_lang.tar. The tar format is known to be treated with most common archivers on Windows like e.g. <ulink url="&url.winzip;">WinZip</ulink>. </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/obtaining.xml +++ phpdoc-es/faq/obtaining.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.obtaining"> <title>Obtaining PHP</title> <titleabbrev>Obtaining PHP</titleabbrev> <para> This section has details about PHP download locations, and OS issues. </para> <qandaset> <qandaentry id="faq.obtaining.where"> <question> <para>Where can I obtain PHP?</para> </question> <answer> <para> You can download PHP from any of the members of the PHP network of sites. These can be found at <ulink url="&url.php;">&url.php;</ulink>. You can also use anonymous CVS to get the absolute latest version of the source. For more information, go to <ulink url="&url.php.anoncvs;">&url.php.anoncvs;</ulink>. </para> </answer> </qandaentry> <qandaentry id="faq.obtaining.precompiled"> <question> <para>Are pre-compiled binary versions available?</para> </question> <answer> <para> We only distribute precompiled binaries for Windows systems, as we are not able to compile PHP for every major Linux/Unix platform with every extension combination. Also note, that many Linux distributions come with PHP built in these days. Windows binaries can be downloaded from our <ulink url="&url.php.downloads;">Downloads</ulink> page, for Linux binaries, please visit your distributions website. </para> </answer> </qandaentry> <qandaentry id="faq.obtaining.optional"> <question> <para> Where can I get libraries needed to compile some of the optional PHP extensions? </para> </question> <answer> <para> <note> <simpara> Those marked with * are not thread-safe libraries, and should not be used with PHP as a server module in the multi-threaded Windows web servers (IIS, Netscape). This does not matter in Unix environments, yet. </simpara> </note> </para> <para> <itemizedlist> <listitem> <simpara> <ulink url="&url.ldap.openldap.source;">LDAP (Unix)</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.ldap.mt;">LDAP* (Unix)</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.ldap.netscape.sdk;">LDAP (Unix/Win)</ulink> : Netscape Directory (LDAP) SDK 1.1. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.ldap.netscape.sdk;">free LDAP server</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.sleepycat;">Berkeley DB2 (Unix/Win)</ulink> : &url.sleepycat;. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.ucd-snmp;">SNMP* (Unix): </ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.gd;">GD* (Unix/Win)</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.msql;">mSQL* (Unix)</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.pgsql;">PostgreSQL (Unix)</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.imap;">IMAP* (Win/Unix)</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.sybase;">Sybase-CT* (Linux, libc5)</ulink> : Available locally. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.freetype;">FreeType (libttf):</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.zlib;">ZLib (Unix/Win32)</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.expat;">expat XML parser (Unix/Win32)</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.pdf;">PDFLib</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.mcrypt;">mcrypt</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.mhash;">mhash</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.t1lib;">t1lib</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.dmalloc;">dmalloc</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.aspell;">aspell</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.readline;">readline</ulink>. </simpara> </listitem> </itemizedlist> </para> </answer> </qandaentry> <qandaentry id="faq.obtaining.how"> <question> <para>How do I get these libraries to work?</para> </question> <answer> <para> You will need to follow instructions provided with the library. Some of these libraries are detected automatically when you run the 'configure' script of PHP (such as the GD library), and others you will have to enable using '<literal>--with-EXTENSION</literal>' options to '<literal>configure</literal>'. Run '<literal>configure --help</literal>' for a listing of these. </para> </answer> </qandaentry> <qandaentry id="faq.obtaining.compileNT"> <question> <para> I got the latest version of the PHP source code from the CVS repository on my Windows machine, what do I need to compile it? </para> </question> <answer> <para> First, you will need Microsoft Visual C++ v6 (v5 may do it also, but we do it with v6), and you will need some support files. See the manual section about <link linkend="install.windows.build">building PHP from source on Windows</link>. </para> </answer> </qandaentry> <qandaentry id="faq.obtaining.browscap"> <question> <para>Where do I find the Browser Capabilities File?</para> </question> <answer> <para> You can find a <filename>browscap.ini</filename> file at <ulink url="&url.browscap.download;">&url.browscap.download;</ulink>. </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/using.xml +++ phpdoc-es/faq/using.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.using"> <title>Using PHP</title> <titleabbrev>Using PHP</titleabbrev> <para> This section gathers many common errors that you may face while writing PHP scripts. </para> <qandaset> <qandaentry id="faq.using.anyform"> <question> <para> I would like to write a generic PHP script that can handle data coming from any form. How do I know which POST method variables are available? </para> </question> <answer> <para> PHP offers many <link linkend="language.variables.predefined"> predefined variables</link>, like the superglobal <varname> $_POST</varname>. You may loop through <varname>$_POST</varname> as it's an associate array of all POSTed values. For example, let's simply loop through it with <link linkend="control-structures.foreach"> foreach</link>, check for <function>empty</function> values, and print them out. <programlisting role="php"> <![CDATA[ <?php $empty = $post = array(); foreach ($_POST as $varname => $varvalue) { if (empty($varvalue)) { $empty[$varname] = $varvalue; } else { $post[$varname] = $varvalue; } } print "<pre>"; if (empty($empty)) { print "None of the POSTed values are empty, posted:\n"; var_dump($post); } else { print "We have " . count($empty) . " empty values\n"; print "Posted:\n"; var_dump($post); print "Empty:\n"; var_dump($empty); exit; } ?> ]]> </programlisting> </para> ¬e.superglobals; </answer> </qandaentry> <qandaentry id="faq.using.addslashes"> <question> <para> I need to convert all single-quotes (') to a backslash followed by a single-quote (\'). How can I do this with a regular expression? I'd also like to convert " to \" and \ to \\. </para> </question> <answer> <para> The function <function>addslashes</function> will do this. See also <function>mysql_escape_string</function>. You may also strip backslashes with <function>stripslashes</function>. </para> ¬e.magicquotes.gpc; </answer> </qandaentry> <qandaentry id="faq.using.stripslashes"> <question> <para> All my " turn into \" and my ' turn into \', how do I get rid of all these unwanted backslashes? How and why did they get there? </para> </question> <answer> <para> The PHP function <function>stripslashes</function> will strip those backslashes from your <type>string</type>. Most likely the backslashes magically exist because the PHP directive <link linkend="ini.magic-quotes-gpc">magic_quotes_gpc</link> is on. </para> ¬e.magicquotes.gpc; </answer> </qandaentry> <qandaentry id="faq.using.wrong-order"> <question> <para> When I do the following, the output is printed in the wrong order: <programlisting role="php"> <![CDATA[ <?php function myfunc($argument) { echo $argument + 10; } $variable = 10; echo "myfunc($variable) = " . myfunc($variable); ?> ]]> </programlisting> what's going on? </para> </question> <answer> <para> To be able to use the results of your function in an expression (such as concatenating it with other strings in the example above), you need to <function>return</function> the value, not <function>echo</function> it. </para> </answer> </qandaentry> <qandaentry id="faq.using.newlines"> <question> <para> Hey, what happened to my newlines? <programlisting role="php"> <![CDATA[ <pre> <?php echo "This should be the first line."; ?> <?php echo "This should show up after the new line above."; ?> </pre> ]]> </programlisting> </para> </question> <answer> <para> In PHP, the ending for a block of code is either "?>" or "?>\n" (where \n means a newline). So in the example above, the echoed sentences will be on one line, because PHP omits the newlines after the block ending. This means that you need to insert an extra newline after each block of PHP code to make it print out one newline. </para> <para> Why does PHP do this? Because when formatting normal HTML, this usually makes your life easier because you don't want that newline, but you'd have to create extremely long lines or otherwise make the raw page source unreadable to achieve that effect. </para> </answer> </qandaentry> <qandaentry id="faq.using.headers-sent"> <question> <para> I get the message 'Warning: Cannot send session cookie - headers already sent...' or 'Cannot add header information - headers already sent...'. </para> </question> <answer> <para> The functions <function>header</function>, <function>setcookie </function>, and the <link linkend="ref.session">session functions</link> need to add headers to the output stream but headers can only be sent before all other content. There can be no output before using these functions, output such as HTML. The function <function> headers_sent</function> will check if your script has already sent headers and see also the <link linkend="ref.outcontrol">Output Control functions</link>. </para> </answer> </qandaentry> <qandaentry id="faq.using.header"> <question> <para> I need to access information in the request header directly. How can I do this? </para> </question> <answer> <para> The <function>getallheaders</function> function will do this if you are running PHP as an Apache module. So, the following bit of code will show you all the request headers: <programlisting role="php"> <![CDATA[ <?php $headers = getallheaders(); foreach ($headers as $name => $content) { echo "headers[$name] = $content<br>\n"; } ?> ]]> </programlisting> </para> <para> See also <function>apache_lookup_uri</function>, <function>apache_response_headers</function>, and <function>fsockopen</function> </para> </answer> </qandaentry> <qandaentry id="faq.using.authentication"> <question> <para> When I try to use authentication with IIS I get 'No Input file specified'. </para> </question> <answer> <para> The security model of IIS is at fault here. This is a problem common to all CGI programs running under IIS. A workaround is to create a plain HTML file (not parsed by PHP) as the entry page into an authenticated directory. Then use a META tag to redirect to the PHP page, or have a link to the PHP page. PHP will then recognize the authentication correctly. With the ISAPI module, this is not a problem. This should not effect other NT web servers. For more information, see: <ulink url="&url.iis;">&url.iis;</ulink> and the manual section on <link linkend="features.http-auth">HTTP Authentication </link>. </para> </answer> </qandaentry> <qandaentry id="faq.using.netscape"> <question> <para> My PHP script works on IE and Lynx, but on Netscape some of my output is missing. When I do a "View Source" I see the content in IE but not in Netscape. </para> </question> <answer> <para> Netscape is more strict regarding html tags (such as tables) then IE. Running your html output through a html validator, such as <ulink url="&url.w3.validator;">validator.w3.org</ulink>, might be helpful. For example, a missing </table> might cause this. </para> <para> Also, both IE and Lynx ignore any NULs (<literal>\0</literal>) in the HTML stream, Netscape does not. The best way to check for this is to compile the <link linkend="features.commandline">command line</link> version of PHP (also known as the CGI version) and run your script from the command line. In *nix, pipe it through <literal>od -c</literal> and look for any <literal>\0</literal> characters. If you are on Windows you need to find an editor or some other program that lets you look at binary files. When Netscape sees a NUL in a file it will typically not output anything else on that line whereas both IE and Lynx will. </para> </answer> </qandaentry> <qandaentry id="faq.using.mixml"> <question> <para> How am I supposed to mix XML and PHP? It complains about my <?xml tags! </para> </question> <answer> <para> In order to embed <?xml straight into your PHP code, you'll have to turn off short tags by having the PHP directive <link linkend="ini.short-open-tag">short_open_tags</link> set to <literal>0</literal>. You cannot set this directive with <function> ini_set</function>. Regardless of <link linkend="ini.short-open-tag"> short_open_tags</link> being on or off, you can do something like: <literal><?php echo '<?xml'; ?></literal>. The default for this directive is on. </para> </answer> </qandaentry> <qandaentry id="faq.using.editor"> <question> <para> How can I use PHP with FrontPage or some other HTML editor that insists on moving my code around? </para> </question> <answer> <para> One of the easiest things to do is to enable using ASP tags in your PHP code. This allows you to use the ASP-style <% and %> code delimiters. Some of the popular HTML editors handle those more intelligently (for now). To enable the ASP-style tags, you need to set the <link linkend="ini.asp-tags">asp_tags</link> &php.ini; variable, or use the appropriate Apache directive. </para> </answer> </qandaentry> <qandaentry id="faq.using.variables"> <question> <para> Where can I find a complete list of variables are available to me in PHP? </para> </question> <answer> <para> Read the manual page on <link linkend="language.variables.predefined"> predefined variables</link> as it includes a partial list of predefined variables available to your script. A complete list of available variables (and much more information) can be seen by calling the <function>phpinfo</function> function. Be sure to read the manual section on <link linkend="language.variables.external">variables from outside of PHP</link> as it describes common scenerios for external variables, like from a HTML form, a Cookie, and the URL. </para> ¬e.registerglobals; </answer> </qandaentry> <qandaentry id="faq.using.cgi-vars"> <question> <para> I'm trying to access one of the standard CGI variables (such as $DOCUMENT_ROOT or $HTTP_REFERER) in a user-defined function, and it can't seem to find it. What's wrong? </para> </question> <answer> <para> It's important to realize that the PHP directive <link linkend="ini.register-globals">register_globals</link> also affects server and environment variables. When register_globals = off (the default is off since PHP 4.2.0), <varname>$DOCUMENT_ROOT</varname> will not exist. Instead, use <varname>$_SERVER['DOCUMENT_ROOT'] </varname>. If register_globals = on then the variables <varname>$DOCUMENT_ROOT</varname> and <varname>$GLOBALS['DOCUMENT_ROOT']</varname> will also exist. </para> <para> If you're sure register_globals = on and wonder why <varname>$DOCUMENT_ROOT</varname> isn't available inside functions, it's because these are like any other variables and would require <literal>global $DOCUMENT_ROOT</literal> inside the function. See also the manual page on <link linkend="language.variables.scope">variable scope</link>. It's preferred to code with register_globals = off. </para> ¬e.superglobals; </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
Index: phpdoc-es/faq/build.xml +++ phpdoc-es/faq/build.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.build"> <title>Build Problems</title> <titleabbrev>Build Problems</titleabbrev> <para> This section gathers most common errors that occur at build time. </para> <qandaset> <qandaentry id="faq.build.configure"> <question> <para> I got the latest version of PHP using the anonymous CVS service, but there's no configure script! </para> </question> <answer> <para> You have to have the GNU autoconf package installed so you can generate the configure script from <filename>configure.in</filename>. Just run <command>./buildconf</command> in the top-level directory after getting the sources from the CVS server. (Also, unless you run configure with the <literal>--enable-maintainer-mode</literal> option, the configure script will not automatically get rebuilt when the <filename>configure.in</filename> file is updated, so you should make sure to do that manually when you notice configure.in has changed. One symptom of this is finding things like @VARIABLE@ in your Makefile after configure or <filename>config.status</filename> is run.) </para> </answer> </qandaentry> <qandaentry id="faq.build.configuring"> <question> <para> I'm having problems configuring PHP to work with Apache. It says it can't find <filename>httpd.h</filename>, but it's right where I said it is! </para> </question> <answer> <para> You need to tell the configure/setup script the location of the top-level of your Apache source tree. This means that you want to specify <literal>--with-apache=/path/to/apache</literal> and <emphasis>not</emphasis> <literal>--with-apache=/path/to/apache/src</literal>. </para> </answer> </qandaentry> <qandaentry id="faq.build.lex"> <question> <para> While configuring PHP (<literal>./configure</literal>), you come across an error similar to the following: </para> <para> <screen> checking lex output file root... ./configure: lex: command not found configure: error: cannot find output from lex; giving up </screen> </para> </question> <answer> <para> Be sure to read the <link linkend="install.unix">installation</link> instructions carefully and note that you need both flex and bison installed to compile PHP. Depending on your setup you will install bison and flex from either source or a package, such as a RPM. </para> </answer> </qandaentry> <qandaentry id="faq.build.apache-sharedcore"> <question> <para> When I try to start Apache, I get the the following message: </para> <para> <screen> fatal: relocation error: file /path/to/libphp4.so: symbol ap_block_alarms: referenced symbol not found </screen> </para> </question> <answer> <para> This error usually comes up when one compiles the Apache core program as a DSO library for shared usage. Try to reconfigure apache, making sure to use at least the following flags: </para> <para> <screen> --enable-shared=max --enable-rule=SHARED_CORE </screen> </para> <para> For more information, read the top-level Apache <filename>INSTALL</filename> file or the Apache <ulink url="&url.apachedso;">DSO manual page</ulink>. </para> </answer> </qandaentry> <qandaentry id="faq.build.not-found"> <question> <para> When I run configure, it says that it can't find the include files or library for GD, gdbm, or some other package! </para> </question> <answer> <para> You can make the configure script looks for header files and libraries in non-standard locations by specifying additional flags to pass to the C preprocessor and linker, such as: <programlisting> <![CDATA[ CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure ]]> </programlisting> If you're using a csh-variant for your login shell (why?), it would be: <programlisting> <![CDATA[ env CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure ]]> </programlisting> </para> </answer> </qandaentry> <qandaentry id="faq.build.yytname"> <question> <para> When it is compiling the file <filename>language-parser.tab.c</filename>, it gives me errors that say <literal>yytname undeclared</literal>. </para> </question> <answer> <para> You need to update your version of Bison. You can find the latest version at <ulink url="&url.bison;">&url.bison;</ulink>. </para> </answer> </qandaentry> <qandaentry id="faq.build.link"> <question> <para> When I run <command>make</command>, it seems to run fine but then fails when it tries to link the final application complaining that it can't find some files. </para> </question> <answer> <para> Some old versions of make that don't correctly put the compiled versions of the files in the functions directory into that same directory. Try running <command>cp *.o functions</command> and then re-running <command>make</command> to see if that helps. If it does, you should really upgrade to a recent version of GNU make. </para> </answer> </qandaentry> <qandaentry id="faq.build.undefined"> <question> <para> When linking PHP, it complains about a number of undefined references. </para> </question> <answer> <para> Take a look at the link line and make sure that all of the appropriate libraries are being included at the end. Common ones that you might have missed are '-ldl' and any libraries required for any database support you included. </para> <para> If you're linking with Apache 1.2.x, did you remember to add the appropriate information to the EXTRA_LIBS line of the Configuration file and re-rerun Apache's Configure script? See the <ulink url="&url.file.installation;">INSTALL</ulink> file that comes with the distribution for more information. </para> <para> Some people have also reported that they had to add '-ldl' immediately following <filename>libphp4.a</filename> when linking with Apache. </para> </answer> </qandaentry> <qandaentry id="faq.build.Apache"> <question> <para> I can't figure out how to build PHP with Apache 1.3. </para> </question> <answer> <para> This is actually quite easy. Follow these steps carefully: <itemizedlist> <listitem> <simpara> Grab the latest Apache 1.3 distribution from <ulink url="&url.apache.source;">&url.apache.source;</ulink>. </simpara> </listitem> <listitem> <simpara> Ungzip and untar it somewhere, for example <filename>/usr/local/src/apache-1.3</filename>. </simpara> </listitem> <listitem> <simpara> Compile PHP by first running <command>./configure --with-apache=/<path>/apache-1.3</command> (substitute <path> for the actual path to your apache-1.3 directory. </simpara> </listitem> <listitem> <simpara> Type <command>make</command> followed by <command>make install</command> to build PHP and copy the necessary files to the Apache distribution tree. </simpara> </listitem> <listitem> <simpara> Change directories into to your <filename>/<path>/apache-1.3/src</filename> directory and edit the <filename>Configuration</filename> file. Add to the file: <literal>AddModule modules/php4/libphp4.a</literal>. </simpara> </listitem> <listitem> <simpara> Type: <command>./configure</command> followed by <literal>make</literal>. </simpara> </listitem> <listitem> <simpara> You should now have a PHP-enabled httpd binary! </simpara> </listitem> </itemizedlist> </para> <para> <emphasis>Note:</emphasis> You can also use the new Apache <literal>./configure</literal> script. See the instructions in the <literal>README.configure</literal> file which is part of your Apache distribution. Also have a look at the <filename>INSTALL</filename> file in the PHP distribution. </para> </answer> </qandaentry> <qandaentry id="faq.build.not-running"> <question> <para> I have followed all the steps to install the Apache module version on UNIX, and my PHP scripts show up in my browser or I am being asked to save the file. </para> </question> <answer> <para> This means that the PHP module is not getting invoked for some reason. Three things to check before asking for further help: <itemizedlist> <listitem> <simpara> Make sure that the httpd binary you are running is the actual new httpd binary you just built. To do this, try running: <literal>/path/to/binary/httpd -l</literal> </simpara> <simpara> If you don't see <filename>mod_php4.c</filename> listed then you are not running the right binary. Find and install the correct binary. </simpara> </listitem> <listitem> <simpara> Make sure you have added the correct Mime Type to one of your <literal>Apache .conf</literal> files. It should be: <literal>AddType application/x-httpd-php3 .php3</literal> (for PHP 3) </simpara> <simpara> or <literal>AddType application/x-httpd-php .php</literal> (for PHP 4) </simpara> <simpara> Also make sure that this AddType line is not hidden away inside a <Virtualhost> or <Directory> block which would prevent it from applying to the location of your test script. </simpara> </listitem> <listitem> <simpara> Finally, the default location of the Apache configuration files changed between Apache 1.2 and Apache 1.3. You should check to make sure that the configuration file you are adding the AddType line to is actually being read. You can put an obvious syntax error into your httpd.conf file or some other obvious change that will tell you if the file is being read correctly. </simpara> </listitem> </itemizedlist> </para> </answer> </qandaentry> <qandaentry id="faq.build.activate-module"> <question> <para> It says to use: <literal>--activate-module=src/modules/php4/libphp4.a</literal>, but that file doesn't exist, so I changed it to <literal>--activate-module=src/modules/php4/libmodphp4.a</literal> and it doesn't work!? What's going on? </para> </question> <answer> <para> Note that the <filename>libphp4.a</filename> file is not supposed to exist. The apache process will create it! </para> </answer> </qandaentry> <qandaentry id="faq.build.ansi"> <question> <para> When I try to build Apache with PHP as a static module using <literal>--activate-module=src/modules/php4/libphp4.a</literal> it tells me that my compiler is not ANSI compliant. </para> </question> <answer> <para> This is a misleading error message from Apache that has been fixed in more recent versions. </para> </answer> </qandaentry> <qandaentry id="faq.build.apxs"> <question> <para> When I try to build PHP using <literal>--with-apxs</literal> I get strange error messages. </para> </question> <answer> <para> There are three things to check here. First, for some reason when Apache builds the apxs Perl script, it sometimes ends up getting built without the proper compiler and flags variables. Find your apxs script (try the command <command>which apxs</command>), it's sometimes found in <filename>/usr/local/apache/bin/apxs</filename> or <filename>/usr/sbin/apxs</filename>. Open it and check for lines similar to these: <programlisting> <![CDATA[ my $CFG_CFLAGS_SHLIB = ' '; # substituted via Makefile.tmpl my $CFG_LD_SHLIB = ' '; # substituted via Makefile.tmpl my $CFG_LDFLAGS_SHLIB = ' '; # substituted via Makefile.tmpl ]]> </programlisting> If this is what you see, you have found your problem. They may contain just spaces or other incorrect values, such as 'q()'. Change these lines to say: <programlisting> <![CDATA[ my $CFG_CFLAGS_SHLIB = '-fpic -DSHARED_MODULE'; # substituted via Makefile.tmpl my $CFG_LD_SHLIB = 'gcc'; # substituted via Makefile.tmpl my $CFG_LDFLAGS_SHLIB = q(-shared); # substituted via Makefile.tmpl ]]> </programlisting> The second possible problem should only be an issue on Red Hat 6.1 and 6.2. The apxs script Red Hat ships is broken. Look for this line: <programlisting> <![CDATA[ my $CFG_LIBEXECDIR = 'modules'; # substituted via APACI install ]]> </programlisting> If you see the above line, change it to this: <programlisting> <![CDATA[ my $CFG_LIBEXECDIR = '/usr/lib/apache'; # substituted via APACI install ]]> </programlisting> Last, if you reconfigure/reinstall Apache, add a <command>make clean</command> to the process after <command>./configure</command> and before <command>make</command>. </para> </answer> </qandaentry> <qandaentry id="faq.build.microtime"> <question> <para> During <command>make</command>, I get errors in microtime, and a lot of <literal>RUSAGE_</literal> stuff. </para> </question> <answer> <para> During the <command>make</command> portion of installation, if you encounter problems that look similar to this: <programlisting> <![CDATA[ microtime.c: In function `php_if_getrusage': microtime.c:94: storage size of `usg' isn't known microtime.c:97: `RUSAGE_SELF' undeclared (first use in this function) microtime.c:97: (Each undeclared identifier is reported only once microtime.c:97: for each function it appears in.) microtime.c:103: `RUSAGE_CHILDREN' undeclared (first use in this function) make[3]: *** [microtime.lo] Error 1 make[3]: Leaving directory `/home/master/php-4.0.1/ext/standard' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/home/master/php-4.0.1/ext/standard' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/master/php-4.0.1/ext' make: *** [all-recursive] Error 1 ]]> </programlisting> </para> <para> Your system is broken. You need to fix your <filename>/usr/include</filename> files by installing a glibc-devel package that matches your glibc. This has absolutely nothing to do with PHP. To prove this to yourself, try this simple test: <programlisting> <![CDATA[ $ cat >test.c <<X #include <sys/resource.h> X $ gcc -E test.c >/dev/null ]]> </programlisting> If that spews out errors, you know your include files are messed up. </para> </answer> </qandaentry> <qandaentry id="faq.build.mysql.tempnam"> <question> <para> When compiling PHP with MySQL, configure runs fine but during <literal>make</literal> I get an error similar to the following: <emphasis>ext/mysql/libmysql/my_tempnam.o(.text+0x46): In function my_tempnam': /php4/ext/mysql/libmysql/my_tempnam.c:103: the use of tempnam' is dangerous, better use mkstemp'</emphasis>, what's wrong? </para> </question> <answer> <para> First, it's important to realize that this is a <literal> Warning</literal> and not a fatal error. Because this is often the last output seen during <literal>make</literal>, it may seem like a fatal error but it's not. Of course, if you set your compiler to die on Warnings, it will. Also keep in mind that MySQL support is enabled by default. </para> </answer> </qandaentry> <qandaentry id="faq.build.upgrade"> <question> <para> I want to upgrade my PHP. Where can I find the <command>./configure</command> line that was used to build my current PHP installation? </para> </question> <answer> <para> Either you look at config.nice file, in the source tree of your current PHP installation or, if this is not available, you simply run a <programlisting> <![CDATA[ <?php phpinfo(); ?> ]]> </programlisting> script. On top of the output the <command>./configure</command> line, that was used to build this PHP installation is shown. </para> </answer> </qandaentry> <qandaentry id="faq.build.gdlibs"> <question> <para> When building PHP with the GD library it either gives strange compile errors or segfaults on execution. </para> </question> <answer> <para> Make sure your GD library and PHP are linked against the same depending libraries (e.g. libpng). </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/com.xml +++ phpdoc-es/faq/com.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.com"> <title>PHP and COM</title> <titleabbrev>PHP and COM</titleabbrev> <para> PHP can be used to access COM and DCOM objects on Win32 platforms. </para> <qandaset> <qandaentry id="faq.com.q1"> <question> <para> I have built a DLL to calculate something. Is there any way to run this DLL under PHP ? </para> </question> <answer> <para> If this is a simple DLL there is no way yet to run it from PHP. If the DLL contains a COM server you may be able to access it if it implements the IDispatch interface. </para> </answer> </qandaentry> <qandaentry id="faq.com.q2"> <question> <para> What does 'Unsupported variant type: xxxx (0xxxxx)' mean ? </para> </question> <answer> <para> There are dozens of VARIANT types and combinations of them. Most of them are already supported but a few still have to be implemented. Arrays are not completely supported. Only single dimensional indexed only arrays can be passed between PHP and COM. If you find other types that aren't supported, please report them as a bug (if not already reported) and provide as much information as available. </para> </answer> </qandaentry> <qandaentry id="faq.com.q3"> <question> <para> Is it possible manipulate visual objects in PHP ? </para> </question> <answer> <para> Generally it is, but as PHP is mostly used as a web scripting language it runs in the web servers context, thus visual objects will never appear on the servers desktop. If you use PHP for application scripting e.g. in conjunction with PHP-GTK there is no limitation in accessing and manipulating visual objects through COM. </para> </answer> </qandaentry> <qandaentry id="faq.com.q4"> <question> <para> Can I store a COM object in a session ? </para> </question> <answer> <para> No, you can't. COM instances are treated as resources and therefore they are only available in a single script's context. </para> </answer> </qandaentry> <qandaentry id="faq.com.q5"> <question> <para> How can I trap COM errors ? </para> </question> <answer> <para> Currently it's not possible to trap COM errors beside the ways provided by PHP itself (@, track_errors, ..), but we are thinking of a way to implement this. </para> </answer> </qandaentry> <qandaentry id="faq.com.q6"> <question> <para> Can I generate DLL files from PHP scripts like i can in Perl ? </para> </question> <answer> <para> No, unfortunately there is no such tool available for PHP. </para> </answer> </qandaentry> <qandaentry id="faq.com.q7"> <question> <para> What does 'Unable to obtain IDispatch interface for CLSID {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}' mean ? </para> </question> <answer> <para> This error can have multiple reasons: <itemizedlist> <listitem> <simpara> the CLSID is wrong </simpara> </listitem> <listitem> <simpara> the requested DLL is missing </simpara> </listitem> <listitem> <simpara> the requested component doesn't implement the IDispatch interface </simpara> </listitem> </itemizedlist> </para> </answer> </qandaentry> <qandaentry id="faq.com.q8"> <question> <para> How can I run COM object from remote server ? </para> </question> <answer> <para> Exactly like you run local objects. You only have to pass the IP of the remote machine as second parameter to the COM constructor. </para> <para> Make sure that you have set <literal>com.allow_dcom=true</literal> in your &php.ini;. </para> </answer> </qandaentry> <qandaentry id="faq.com.q9"> <question> <para> I get 'DCOM is disabled in C:\path...\scriptname.php on line 6', what can I do ? </para> </question> <answer> <para> Edit your &php.ini; and set <literal>com.allow_dcom=true</literal>. </para> </answer> </qandaentry> <qandaentry id="faq.com.q10"> <question> <para> Is it possible to load/manipulate an ActiveX object in a page with PHP ? </para> </question> <answer> <para> This has nothing to do with PHP. ActiveX objects are loaded on client side if they are requested by the HTML document. There is no relation to the PHP script and therefore there is no direct server side interaction possible. </para> </answer> </qandaentry> <qandaentry id="faq.com.q11"> <question> <para> Is it possible to get a running instance of a component ? </para> </question> <answer> <para> This is possible with the help of monikers. If you want to get multiple references to the same word instance you can create that instance like shown: </para> <programlisting role="php"> $word = new COM("C:\docs\word.doc"); </programlisting> <para> This will create a new instance if there is no running instance available or it will return a handle to the running instance, if available. </para> </answer> </qandaentry> <qandaentry id="faq.com.q12"> <question> <para> Is there a way to handle an event sent from COM object ? </para> </question> <answer> <para> Starting in PHP 4.3.0, you can define an event sink and bind it as shown in the example below. You can use <function>com_print_typeinfo</function> to have PHP generate a skeleton for the event sink class. <example> <title>COM event sink example</title> <programlisting role="php"> <![CDATA[ <?php class IEEventSinker { var $terminated = false; function ProgressChange($progress, $progressmax) { echo "Download progress: $progress / $progressmax\n"; } function DocumentComplete(&$dom, $url) { echo "Document $url complete\n"; } function OnQuit() { echo "Quit!\n"; $this->terminated = true; } } $ie = new COM("InternetExplorer.Application"); $sink =& new IEEventSinker(); com_event_sink($ie, $sink, "DWebBrowserEvents2"); $ie->Visible = true; $ie->Navigate("http://www.php.net"); while(!$sink->terminated) { com_message_pump(4000); } $ie = null; ?> ]]> </programlisting> </example> </para> </answer> </qandaentry> <qandaentry id="faq.com.q13"> <question> <para> I'm having problems when trying to invoke a method of a COM object which exposes more than one interface. What can I do ? </para> </question> <answer> <para> The answer is as simple as unsatisfying. I don't know exactly but i think you can do nothing. If someone has specific information about this, please let <ulink url="mailto:&email.harald;">me</ulink> know :) </para> </answer> </qandaentry> <qandaentry id="faq.com.q14"> <question> <para> So PHP works with COM, how about COM+ ? </para> </question> <answer> <para> COM+ extends COM by a framework for managing components through MTS and MSMQ but there is nothing special that PHP has to support to use such components. </para> </answer> </qandaentry> <qandaentry id="faq.com.q15"> <question> <para> If PHP can manipulate COM objects, can we imagine to use MTS to manage components resources, in conjunction with PHP ? </para> </question> <answer> <para> PHP itself doesn't handle transactions yet. Thus if an error occurs no rollback is initiated. If you use components that support transactions you will have to implement the transaction management yourself. </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/databases.xml +++ phpdoc-es/faq/databases.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.databases"> <title>Database issues</title> <titleabbrev>Database issues</titleabbrev> <para> This section holds common questions about relation between PHP and databases. Yes, PHP can access virtually any database available today. </para> <qandaset> <qandaentry id="faq.databases.mssql"> <question> <para> I heard it's possible to access Microsoft SQL Server from PHP. How? </para> </question> <answer> <para> On Windows machines, you can simply use the included ODBC support and the correct ODBC driver. </para> <para> On Unix machines, you can use the Sybase-CT driver to access Microsoft SQL Servers because they are (at least mostly) protocol-compatible. Sybase has made a <ulink url="&url.sybase.ctlib;">free version of the necessary libraries for Linux systems</ulink>. For other Unix operating systems, you need to contact Sybase for the correct libraries. Also see the answer to the next question. </para> </answer> </qandaentry> <qandaentry id="faq.databases.access"> <question> <para>Can I access Microsoft Access databases?</para> </question> <answer> <para> Yes. You already have all the tools you need if you are running entirely under Windows 9x/Me, or NT/2000, where you can use ODBC and Microsoft's ODBC drivers for Microsoft Access databases. </para> <para> If you are running PHP on a Unix box and want to talk to MS Access on a Windows box you will need Unix ODBC drivers. <ulink url="&url.openlink;">OpenLink Software</ulink> has Unix-based ODBC drivers that can do this. There is a free pilot program where you can download an evaluation copy that doesn't expire and prices start at $675 for the commercial supported version. </para> <para> Another alternative is to use an SQL server that has Windows ODBC drivers and use that to store the data, which you can then access from Microsoft Access (using ODBC) and PHP (using the built in drivers), or to use an intermediary file format that Access and PHP both understand, such as flat files or dBase databases. On this point Tim Hayes from OpenLink software writes: <programlisting> Using another database as an intermediary is not a good idea, when you can use ODBC from PHP straight to your database - i.e. with OpenLink's drivers. If you do need to use an intermediary file format, OpenLink have now released Virtuoso (a virtual database engine) for NT, Linux and other unix platforms. Please visit our <ulink url="&url.openlink;">website</ulink> for a free download. </programlisting> </para> <para> One option that has proven successful is to use MySQL and its MyODBC drivers on Windows and synchronizing the databases. Steve Lawrence writes: </para> <para> <itemizedlist> <listitem> <simpara> Install MySQL on your platform according to instructions with MySQL. Latest available from <ulink url="&url.mysql;">www.mysql.com</ulink> (get it from your mirror!). No special configuration required except when you set up a database, and configure the user account, you should put % in the host field, or the host name of the Windows computer you wish to access MySQL with. Make a note of your server name, username, and password. </simpara> </listitem> <listitem> <simpara> Download the MyODBC for Windows driver from the MySQL site. Latest release is myodbc-2_50_19-win95.zip (NT available too, as well as source code). Install it on your Windows machine. You can test the operation with the utilities included with this program. </simpara> </listitem> <listitem> <simpara> Create a user or system dsn in your ODBC administrator, located in the control panel. Make up a dsn name, enter your hostname, user name, password, port, etc for you MySQL database configured in step 1. </simpara> </listitem> <listitem> <simpara> Install Access with a full install, this makes sure you get the proper add-ins.. at the least you will need ODBC support and the linked table manager. </simpara> </listitem> <listitem> <simpara> Now the fun part! Create a new access database. In the table window right click and select Link Tables, or under the file menu option, select Get External Data and then Link Tables. When the file browser box comes up, select files of type: ODBC. Select System dsn and the name of your dsn created in step 3. Select the table to link, press OK, and presto! You can now open the table and add/delete/edit data on your MySQL server! You can also build queries, import/export tables to MySQL, build forms and reports, etc. </simpara> </listitem> </itemizedlist> </para> <para> Tips and Tricks: <itemizedlist> <listitem> <simpara> You can construct your tables in Access and export them to MySQL, then link them back in. That makes table creation quick. </simpara> </listitem> <listitem> <simpara> When creating tables in Access, you must have a primary key defined in order to have write access to the table in access. Make sure you create a primary key in MySQL before linking in access </simpara> </listitem> <listitem> <simpara> If you change a table in MySQL, you have to re-link it in Access. Go to tools>add-ins>linked table manager, cruise to your ODBC DSN, and select the table to re-link from there. you can also move your dsn source around there, just hit the always prompt for new location checkbox before pressing OK. </simpara> </listitem> </itemizedlist> </para> </answer> </qandaentry> <qandaentry id="faq.databases.upgraded"> <question> <para> I upgraded to PHP 4, and now mysql keeps telling me "Warning: MySQL: Unable to save result set in ...". What's up? </para> </question> <answer> <para> Most likely what has happened is, PHP 4 was compiled with the '--with-mysql' option, without specifying the path to MySQL. This means PHP is using its built-in MySQL client library. If your system is running applications, such as PHP 3 as a concurrent Apache module, or auth-mysql, that use other versions of MySQL clients, then there is a conflict between the two differing versions of those clients. </para> <para> Recompiling PHP 4, and adding the path to MySQL to the flag, '<link linkend="mysql.configure">--with-mysql=/your/path/to/mysql</link>' usually solves the problem. </para> </answer> </qandaentry> <qandaentry id="faq.databases.shared-mysql"> <question> <para> After installing shared MySQL support, Apache dumps core as soon as libphp4.so is loaded. Can this be fixed? </para> </question> <answer> <para> If your MySQL libs are linked against pthreads this will happen. Check using ldd. If they are, grab the MySQL tarball and compile from source, or recompile from the source rpm and remove the switch in the spec file that turns on the threaded client code. Either of these suggestions will fix this. Then recompile PHP with the new MySQL libs. </para> </answer> </qandaentry> <qandaentry id="faq.databases.mysqlresource"> <question> <para> Why do I get an error that looks something like this: "Warning: 0 is not a MySQL result index in <file> on line <x>" or "Warning: Supplied argument is not a valid MySQL result resource in <file> on line <x>? </para> </question> <answer> <para> You are trying to use a result identifier that is 0. The 0 indicates that your query failed for some reason. You need to check for errors after submitting a query and before you attempt to use the returned result identifier. The proper way to do this is with code similar to the following: <programlisting role="php"> $result = mysql_query("SELECT * FROM tables_priv"); if (!$result) { echo mysql_error(); exit; } </programlisting> or <programlisting role="php"> $result = mysql_query("SELECT * FROM tables_priv") or die("Bad query: ".mysql_error()); </programlisting> </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/general.xml +++ phpdoc-es/faq/general.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.general"> <title>General Information</title> <titleabbrev>General Information</titleabbrev> <para> This section holds the most general questions about PHP: what it is and what it does. </para> <qandaset> <qandaentry id="faq.general.what"> <question> <para>What is PHP?</para> </question> <answer> <para> From the <link linkend="preface">preface of the manual</link>: </para> <para> PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly. </para> <para> A nice introduction to PHP by Stig Sæther Bakken can be found <ulink url="&url.zend.introduction;">here</ulink> on the Zend website. Also, much of the <ulink url="&url.php.conf;">PHP Conference Material</ulink> is freely available. </para> </answer> </qandaentry> <qandaentry id="faq.general.acronym"> <question> <para>What does PHP stand for?</para> </question> <answer> <para> PHP stands for <emphasis>PHP: Hypertext Preprocessor</emphasis>. This confuses many people because the first word of the acronym is the acronym. This type of acronym is called a recursive acronym. The curious can visit <ulink url="&url.foldoc;">Free On-Line Dictionary of Computing</ulink> for more information on recursive acronyms. </para> </answer> </qandaentry> <qandaentry id="faq.general.relation-versions"> <question> <para>What is the relation between the versions?</para> </question> <answer> <para> PHP/FI 2.0 is an early and no longer supported version of PHP. PHP 3 is the successor to PHP/FI 2.0 and is a lot nicer. PHP 4 is the current generation of PHP, which uses the <ulink url="&url.zend;">Zend engine</ulink> under the hood. PHP 5 uses <ulink url="&url.zend.future;">Zend engine 2</ulink> which, among other things, offers many additional <link linkend="ref.classobj">OOP</link> features. PHP 5 is experimental. </para> </answer> </qandaentry> <qandaentry id="faq.general.running-concurent"> <question> <para>Can I run several versions of PHP at the same time?</para> </question> <answer> <para> Yes. See the <filename>INSTALL</filename> file that is included in the PHP 4 source distribution. Also, read the related <link linkend="migration4.php4.with.php3">appendix</link>. </para> </answer> </qandaentry> <qandaentry id="faq.general.differences-34"> <question> <para>What are the differences between PHP 3 and PHP 4?</para> </question> <answer> <para> There are <ulink url="&url.zend.articles;">a couple of articles</ulink> written on this by the authors of PHP 4. Here's a list of some of the more important new features: <itemizedlist> <listitem> <simpara>Extended API module</simpara> </listitem> <listitem> <simpara>Generalized build process under UNIX</simpara> </listitem> <listitem> <simpara>Generic web server interface that also supports multi-threaded web servers</simpara> </listitem> <listitem> <simpara>Improved syntax highlighter</simpara> </listitem> <listitem> <simpara>Native HTTP session support</simpara> </listitem> <listitem> <simpara>Output buffering support</simpara> </listitem> <listitem> <simpara>More powerful configuration system</simpara> </listitem> <listitem> <simpara>Reference counting</simpara> </listitem> </itemizedlist> Please see the <ulink url="&url.zend.new;">What's new in PHP 4 overview</ulink> for a detailed explanation of these features and more. If you're migrating from PHP 3 to PHP 4, also read the related <link linkend="migration4">appendix</link>. </para> </answer> </qandaentry> <qandaentry id="faq.general.bug"> <question> <para> I think I found a bug! Who should I tell? </para> </question> <answer> <para> You should go to the PHP Bug Database and make sure the bug isn't a known bug. If you don't see it in the database, use the reporting form to report the bug. It is important to use the bug database instead of just sending an email to one of the mailing lists because the bug will have a tracking number assigned and it will then be possible for you to go back later and check on the status of the bug. The bug database can be found at <ulink url="&url.php.bugs;">&url.php.bugs;</ulink>. </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/html.xml +++ phpdoc-es/faq/html.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.html"> <title>PHP and HTML</title> <titleabbrev>PHP and HTML</titleabbrev> <para> PHP and HTML interact a lot: PHP can generate HTML, and HTML can pass information to PHP. Before reading these faqs, it's important you learn how to <link linkend="language.variables.external"> retrieve variables from outside of PHP</link>. The manual page on this topic includes many examples as well. Pay close attention to what <literal>register_globals</literal> means to you too. </para> <qandaset> <qandaentry id="faq.html.encoding"> <question> <para> What encoding/decoding do I need when I pass a value through a form/URL? </para> </question> <answer> <para> There are several stages for which encoding is important. Assuming that you have a <type>string</type> <varname>$data</varname>, which contains the string you want to pass on in a non-encoded way, these are the relevant stages: <itemizedlist> <listitem> <para> HTML interpretation. In order to specify a random string, you <emphasis>must</emphasis> include it in double quotes, and <function>htmlspecialchars</function> the whole value. </para> </listitem> <listitem> <para> URL: A URL consists of several parts. If you want your data to be interpreted as one item, you <emphasis>must</emphasis> encode it with <function>urlencode</function>. </para> </listitem> </itemizedlist> </para> <para> <example> <title>A hidden HTML form element</title> <programlisting role="php"> <![CDATA[ <?php echo "<input type=hidden value=\"" . htmlspecialchars($data) . "\">\n"; ?> ]]> </programlisting> </example> <note> <simpara> It is wrong to <function>urlencode</function> <varname>$data</varname>, because it's the browsers responsibility to <function>urlencode</function> the data. All popular browsers do that correctly. Note that this will happen regardless of the method (i.e., GET or POST). You'll only notice this in case of GET request though, because POST requests are usually hidden. </simpara> </note> <example> <title>Data to be edited by the user</title> <programlisting role="php"> <![CDATA[ <?php echo "<textarea name=mydata>\n"; echo htmlspecialchars($data)."\n"; echo "</textarea>"; ?> ]]> </programlisting> </example> <note> <simpara> The data is shown in the browser as intended, because the browser will interpret the HTML escaped symbols. </simpara> <simpara> Upon submitting, either via GET or POST, the data will be urlencoded by the browser for transferring, and directly urldecoded by PHP. So in the end, you don't need to do any urlencoding/urldecoding yourself, everything is handled automagically. </simpara> </note> <example> <title>In an URL</title> <programlisting role="php"> <![CDATA[ <?php echo "<a href=\"" . htmlspecialchars("/nextpage.php?stage=23&data=" . urlencode($data)) . "\">\n"; ?> ]]> </programlisting> </example> <note> <simpara> In fact you are faking a HTML GET request, therefore it's necessary to manually <function>urlencode</function> the data. </simpara> </note> <note> <simpara> You need to <function>htmlspecialchars</function> the whole URL, because the URL occurs as value of an HTML-attribute. In this case, the browser will first un-<function>htmlspecialchars</function> the value, and then pass the URL on. PHP will understand the URL correctly, because you <function>urlencoded</function> the data. </simpara> <simpara> You'll notice that the <literal>&</literal> in the URL is replaced by <literal>&amp;</literal>. Although most browsers will recover if you forget this, this isn't always possible. So even if your URL is not dynamic, you <emphasis>need</emphasis> to <function>htmlspecialchars</function> the URL. </simpara> </note> </para> <!-- TODO: a note about addgpcslashes? --> </answer> </qandaentry> <qandaentry id="faq.html.form-image"> <question> <para> I'm trying to use an <input type="image"> tag, but the <varname>$foo.x</varname> and <varname>$foo.y</varname> variables aren't available. <varname>$_GET['foo.x']</varname> isn't existing either. Where are they? </para> </question> <answer> <para> When submitting a form, it is possible to use an image instead of the standard submit button with a tag like: <programlisting role="html"> <![CDATA[ <input type="image" src="image.gif" name="foo"> ]]> </programlisting> When the user clicks somewhere on the image, the accompanying form will be transmitted to the server with two additional variables: <varname>foo.x</varname> and <varname>foo.y</varname>. </para> <para> Because <varname>foo.x</varname> and <varname>foo.y</varname> would make invalid variable names in PHP, they are automagically converted to <varname>foo_x</varname> and <varname>foo_y</varname>. That is, the periods are replaced with underscores. So, you'd access these variables like any other described within the section on retrieving <link linkend="language.variables.external">variables from outside of PHP</link>. For example, <varname>$_GET['foo_x']</varname>. </para> </answer> </qandaentry> <qandaentry id="faq.html.arrays"> <question> <para>How do I create arrays in a HTML <form>?</para> </question> <answer> <para> To get your <form> result sent as an <link linkend="language.types.array">array</link> to your PHP script you name the <input>, <select> or <textarea> elements like this: <programlisting role="html"> <![CDATA[ <input name="MyArray[]"> <input name="MyArray[]"> <input name="MyArray[]"> <input name="MyArray[]"> ]]> </programlisting> Notice the square brackets after the variable name, that's what makes it an array. You can group the elements into different arrays by assigning the same name to different elements: <programlisting role="html"> <![CDATA[ <input name="MyArray[]"> <input name="MyArray[]"> <input name="MyOtherArray[]"> <input name="MyOtherArray[]"> ]]> </programlisting> This produces two arrays, MyArray and MyOtherArray, that gets sent to the PHP script. It's also possible to assign specific keys to your arrays: <programlisting role="html"> <![CDATA[ <input name="AnotherArray[]"> <input name="AnotherArray[]"> <input name="AnotherArray[email]"> <input name="AnotherArray[phone]"> ]]> </programlisting> The AnotherArray array will now contain the keys 0, 1, email and phone. </para> <para> <note> <para> Specifying an arrays key is optional in HTML. If you do not specify the keys, the array gets filled in the order the elements appear in the form. Our first example will contain keys 0, 1, 2 and 3. </para> </note> </para> <para> See also <link linkend="ref.array">Array Functions</link> and <link linkend="language.variables.external">Variables from outside PHP</link>. </para> </answer> </qandaentry> <qandaentry id="faq.html.select-multiple"> <question> <para> How do I get all the results from a select multiple HTML tag? </para> </question> <answer> <para> The select multiple tag in an HTML construct allows users to select multiple items from a list. These items are then passed to the action handler for the form. The problem is that they are all passed with the same widget name. ie. <programlisting role="html"> <![CDATA[ <select name="var" multiple> ]]> </programlisting> Each selected option will arrive at the action handler as: <programlisting> var=option1 var=option2 var=option3 </programlisting> Each option will overwrite the contents of the previous <varname>$var</varname> variable. The solution is to use PHP's "array from form element" feature. The following should be used: <programlisting role="html"> <![CDATA[ <select name="var[]" multiple> ]]> </programlisting> This tells PHP to treat <varname>$var</varname> as an array and each assignment of a value to var[] adds an item to the array. The first item becomes <varname>$var[0]</varname>, the next <varname>$var[1]</varname>, etc. The <function>count</function> function can be used to determine how many options were selected, and the <function>sort</function> function can be used to sort the option array if necessary. </para> <para> Note that if you are using JavaScript the <literal>[]</literal> on the element name might cause you problems when you try to refer to the element by name. Use it's numerical form element ID instead, or enclose the variable name in single quotes and use that as the index to the elements array, for example: <programlisting> variable = documents.forms[0].elements['var[]']; </programlisting> </para> </answer> </qandaentry> <qandaentry id="faq.html.javascript-variable"> <question> <para> How can I pass a variable from Javascript to PHP? </para> </question> <answer> <para> Since Javascript is (usually) a client-side technology, and PHP is (usually) a server-side technology, and since HTTP is a "stateless" protocol, the two languages cannot directly share variables. </para> <para> It is, however, possible to pass variables between the two. One way of accomplishing this is to generate Javascript code with PHP, and have the browser refresh itself, passing specific variables back to the PHP script. The example below shows precisely how to do this -- it allows PHP code to capture screen height and width, something that is normally only possible on the client side. </para> <para> <programlisting> <![CDATA[ <?php if (isset($_GET['width']) AND isset($_GET['height'])) { // output the geometry variables echo "Screen width is: ". $_GET['width'] ."<br />\n"; echo "Screen height is: ". $_GET['height'] ."<br />\n"; } else { // pass the geometry variables // (preserve the original query string // -- post variables will need to handled differently) echo "<script language=\"javascript\">\n"; echo " location.href=\"${_SERVER['SCRIPT_NAME']}?${_SERVER['QUERY_STRING']}" . "&width=\" + screen.width + \"&height=\" + screen.height;\n"; echo "</script>\n"; exit(); } ?> ]]> </programlisting> </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/installation.xml +++ phpdoc-es/faq/installation.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.installation"> <title>Installation</title> <titleabbrev>Installation</titleabbrev> <para> This section holds common questions about the way to install PHP. PHP is available for almost any OS (except maybe for MacOS before OSX), and almost any web server. </para> <para> To install PHP, follow the instructions in the <ulink url="&url.file.installation;">INSTALL</ulink> file located in the distribution. Windows users should also read the <ulink url="&url.file.readmewin;">install.txt</ulink> file. There are also some helpful hints for Windows users <link linkend="install.windows">here</link>. </para> <qandaset> <qandaentry id="faq.installation.phpini"> <question> <para> Unix/Windows: Where should my &php.ini; file be located? </para> </question> <answer> <para> By default on UNIX it should be in <filename>/usr/local/lib</filename> which is <filename><install-path>/lib</filename>. Most people will want to change this at compile-time with the <link linkend="install.configure.with-config-file-path">--with-config-file-path</link> flag. You would, for example, set it with something like: <programlisting> --with-config-file-path=/etc </programlisting> And then you would copy <filename>php.ini-dist</filename> from the distribution to <filename>/etc/php.ini</filename> and edit it to make any local changes you want. </para> <programlisting> --with-config-file-scan-dir=PATH </programlisting> <para> On Windows the default path for the &php.ini; file is the Windows directory. If you're using the Apache webserver, &php.ini; is first searched in the Apaches install directory, e.g. <filename>c:\program files\apache group\apache</filename>. This way you can have different &php.ini; files for different versions of Apache on the same machine. </para> <para> See also the chapter about the <link linkend="configuration.file">configuration file</link>. </para> </answer> </qandaentry> <qandaentry id="faq.installation.nodata"> <question> <para> Unix: I installed PHP, but every time I load a document, I get the message 'Document Contains No Data'! What's going on here? </para> </question> <answer> <para> This probably means that PHP is having some sort of problem and is core-dumping. Look in your server error log to see if this is the case, and then try to reproduce the problem with a small test case. If you know how to use 'gdb', it is very helpful when you can provide a backtrace with your bug report to help the developers pinpoint the problem. If you are using PHP as an Apache module try something like: <itemizedlist> <listitem> <para> Stop your httpd processes </para> </listitem> <listitem> <para> gdb httpd </para> </listitem> <listitem> <para> Stop your httpd processes </para> </listitem> <listitem> <para> > run -X -f /path/to/httpd.conf </para> </listitem> <listitem> <para> Then fetch the URL causing the problem with your browser </para> </listitem> <listitem> <para> > run -X -f /path/to/httpd.conf </para> </listitem> <listitem> <para> If you are getting a core dump, gdb should inform you of this now </para> </listitem> <listitem> <para> type: bt </para> </listitem> <listitem> <para> You should include your backtrace in your bug report. This should be submitted to <ulink url="&url.php.bugs;">&url.php.bugs;</ulink> </para> </listitem> </itemizedlist> </para> <para> If your script uses the regular expression functions (<function>ereg</function> and friends), you should make sure that you compiled PHP and Apache with the same regular expression package. This should happen automatically with PHP and Apache 1.3.x </para> </answer> </qandaentry> <qandaentry id="faq.installation.processing"> <question> <para> Unix: I installed PHP using RPMS, but Apache isn't processing the PHP pages! What's going on here? </para> </question> <answer> <para> Assuming you installed both Apache and PHP from RPM packages, you need to uncomment or add some or all of the following lines in your &httpd.conf; file: <programlisting> # Extra Modules AddModule mod_php.c AddModule mod_php3.c AddModule mod_perl.c # Extra Modules LoadModule php_module modules/mod_php.so LoadModule php3_module modules/libphp3.so /* for PHP 3 */ LoadModule php4_module modules/libphp4.so /* for PHP 4 */ LoadModule perl_module modules/libperl.so </programlisting> And add: <programlisting> AddType application/x-httpd-php3 .php3 /* for PHP 3 */ AddType application/x-httpd-php .php /* for PHP 4 */ </programlisting> ... to the global properties, or to the properties of the VirtualDomain you want to have PHP support added to. </para> </answer> </qandaentry> <qandaentry id="faq.installation.compile"> <question> <para> Unix: I installed PHP 3 using RPMS, but it doesn't compile with the database support I need! What's going on here? </para> </question> <answer> <para> Due to the way PHP 3 built, it is not easy to build a complete flexible PHP RPM. This issue is addressed in PHP 4. For PHP 3, we currently suggest you use the mechanism described in the INSTALL.REDHAT file in the PHP distribution. If you insist on using an RPM version of PHP 3, read on... </para> <para> The RPM packagers are setting up the RPMS to install without database support to simplify installations <emphasis>and</emphasis> because RPMS use /usr/ instead of the standard /usr/local/ directory for files. You need to tell the RPM spec file which databases to support and the location of the top-level of your database server. </para> <para> This example will explain the process of adding support for the popular MySQL database server, using the mod installation for Apache. </para> <para> Of course all of this information can be adjusted for any database server that PHP supports. We will assume you installed MySQL and Apache completely with RPMS for this example as well. <itemizedlist> <listitem> <para> First remove mod_php3 : <programlisting> rpm -e mod_php3 </programlisting> </para> </listitem> <listitem> <para> Then get the source rpm and INSTALL it, NOT --rebuild <programlisting> rpm -Uvh mod_php3-3.0.5-2.src.rpm </programlisting> </para> </listitem> <listitem> <para> Then edit the <filename>/usr/src/redhat/SPECS/mod_php3.spec</filename> file </para> <para> In the %build section add the database support you want, and the path. </para> <para> For MySQL you would add <programlisting> --with-mysql=/usr \ </programlisting> The %build section will look something like this: <programlisting> ./configure --prefix=/usr \ --with-apxs=/usr/sbin/apxs \ --with-config-file-path=/usr/lib \ --enable-debug=no \ --enable-safe-mode \ --with-exec-dir=/usr/bin \ --with-mysql=/usr \ --with-system-regex </programlisting> </para> </listitem> <listitem> <para> Once this modification is made then build the binary rpm as follows: <programlisting> rpm -bb /usr/src/redhat/SPECS/mod_php3.spec </programlisting> </para> </listitem> <listitem> <para> Then install the rpm <programlisting> rpm -ivh /usr/src/redhat/RPMS/i386/mod_php3-3.0.5-2.i386.rpm </programlisting> </para> </listitem> </itemizedlist> Make sure you restart Apache, and you now have PHP 3 with MySQL support using RPM's. Note that it is probably much easier to just build from the distribution tarball of PHP 3 and follow the instructions in <filename>INSTALL.REDHAT</filename> found in that distribution. </para> </answer> </qandaentry> <qandaentry id="faq.installation.frontpage"> <question> <para> Unix: I patched Apache with the FrontPage extensions patch, and suddenly PHP stopped working. Is PHP incompatible with the Apache FrontPage extensions? </para> </question> <answer> <para> No, PHP works fine with the FrontPage extensions. The problem is that the FrontPage patch modifies several Apache structures, that PHP relies on. Recompiling PHP (using 'make clean ; make') after the FP patch is applied would solve the problem. </para> </answer> </qandaentry> <qandaentry id="faq.installation.blankscreen"> <question> <para> Unix/Windows: I have installed PHP, but when I try to access a PHP script file via my browser, I get a blank screen. </para> </question> <answer> <para> Do a 'view source' in the web browser and you will probably find that you can see the source code of your PHP script. This means that the web server did not send the script to PHP for interpretation. Something is wrong with the server configuration - double check the server configuration against the PHP installation instructions. </para> </answer> </qandaentry> <qandaentry id="faq.installation.500error"> <question> <para> Unix/Windows: I have installed PHP, but when try to access a PHP script file via my browser, I get a server 500 error. </para> </question> <answer> <para> Something went wrong when the server tried to run PHP. To get to see a sensible error message, from the command line, change to the directory containing the PHP executable (<filename>php.exe</filename> on Windows) and run <literal>php -i</literal>. If PHP has any problems running, then a suitable error message will be displayed which will give you a clue as to what needs to be done next. If you get a screen full of html codes (the output of the <function>phpinfo</function> function) then PHP is working, and your problem may be related to your server configuration which you should double check. </para> </answer> </qandaentry> <qandaentry id="faq.installation.undefinedsyms"> <question> <para> Some operating systems: I have installed PHP without errors, but when I try to start apache I get undefined symbol errors: <programlisting> [mybox:user /src/php4] root# apachectl configtest apachectl: /usr/local/apache/bin/httpd Undefined symbols: _compress _uncompress </programlisting> </para> </question> <answer> <para> This has actually nothing to do with PHP, but with the MySQL client libraries. Some need --with-zlib, others do not. This is also covered in the MySQL FAQ. </para> </answer> </qandaentry> <qandaentry id="faq.installation.cgierror"> <question> <para> Windows: I have installed PHP, but when I to access a PHP script file via my browser, I get the error: <programlisting> cgi error: The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are: </programlisting> </para> </question> <answer> <para> This error message means that PHP failed to output anything at all. To get to see a sensible error message, from the command line, change to the directory containing the PHP executable (<filename>php.exe</filename> on Windows) and run <literal>php -i</literal>. If PHP has any problems running, then a suitable error message will be displayed which will give you a clue as to what needs to be done next. If you get a screen full of html codes (the output of the <function>phpinfo</function> function) then PHP is working. </para> <para> Once PHP is working at the command line, try accessing the script via the browser again. If it still fails then it could be one of the following: </para> <itemizedlist> <listitem> <simpara> File permissions on your PHP script, <filename>php.exe</filename>, <filename>php4ts.dll</filename>, &php.ini; or any PHP extensions you are trying to load are such that the anonymous internet user <literal>ISUR_<machinename></literal> cannot access them. </simpara> </listitem> <listitem> <simpara> The script file does not exist (or possibly isn't where you think it is relative to your web root directory). Note that for IIS you can trap this error by ticking the 'check file exists' box when setting up the script mappings in the Internet Services Manager. If a script file does not exist then the server will return a 404 error instead. There is also the additional benefit that IIS will do any authentication required for you based on the NTLanMan permissions on your script file. </simpara> </listitem> </itemizedlist> </answer> </qandaentry> <qandaentry id="faq.installation.phpandiis"> <question> <para> Windows: I've followed all the instructions, but still can't get PHP and IIS to work together! </para> </question> <answer> <para> Make sure any user who needs to run a PHP script has the rights to run <filename>php.exe</filename>! IIS uses an anonymous user which is added at the time IIS is installed. This user needs rights to <filename>php.exe</filename>. Also, any authenticated user will also need rights to execute <filename>php.exe</filename>. And for IIS4 you need to tell it that PHP is a script engine. Also, you will want to read <link linkend="faq.installation.forceredirect">this faq</link>. </para> </answer> </qandaentry> <qandaentry id="faq.installation.forceredirect"> <question> <para> When running PHP as CGI with IIS, PWS, OmniHTTPD or Xitami, I get the following error: <literal>Security Alert! PHP CGI cannot be accessed directly.</literal>. </para> </question> <answer> <para> You must set the <link linkend="ini.cgi.force-redirect"> cgi.force_redirect</link> directive to <literal>0</literal>. It defaults to <literal>1</literal> so be sure the directive isn't commented out (with a <literal>;</literal>). Like all directives, this is set in &php.ini; </para> <para> Because the default is <literal>1</literal>, it's critical that you're 100% sure that the correct &php.ini; file is being read. Read <link linkend="faq.installation.findphpini">this faq</link> for details. </para> </answer> </qandaentry> <qandaentry id="faq.installation.findphpini"> <question> <para> How do I know if my &php.ini; is being found and read? It seems like it isn't as my changes aren't being implemented. </para> </question> <answer> <para> To be sure your &php.ini; is being read by PHP, make a call to <function>phpinfo</function> and near the top will be a listing called <literal>Configuration File (php.ini)</literal>. This will tell you where PHP is looking for &php.ini; and whether or not it's being read. If just a directory PATH exists than it's not being read and you should put your &php.ini; in that directory. If &php.ini; is included within the PATH than it is being read. </para> <para> If &php.ini; is being read and you're running PHP as a module then be sure to restart PHP after making changes to &php.ini; </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/languages.xml +++ phpdoc-es/faq/languages.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.languages"> <title>PHP and other languages</title> <titleabbrev>PHP and other languages</titleabbrev> <para> PHP is the best language for web programing, but what about other languages? </para> <qandaset> <qandaentry id="faq.languages.asp"> <question> <para>PHP vs. ASP?</para> </question> <answer> <para> ASP is not really a language in itself, it's an acronym for Active Server Pages, the actual language used to program ASP with is Visual Basic Script or JScript. The biggest drawback of ASP is that it's a proprietary system that is natively used only on Microsoft Internet Information Server (IIS). This limits it's availability to Win32 based servers. There are a couple of projects in the works that allows ASP to run in other environments and webservers: <ulink url="&url.instantasp;">InstantASP</ulink> from <ulink url="&url.halcyon;">Halcyon</ulink> (commercial), <ulink url="&url.chilisoft.asp;">Chili!Soft ASP</ulink> from <ulink url="&url.chilisoft;">Chili!Soft</ulink> (commercial) and <ulink url="&url.openasp;">OpenASP from ActiveScripting.org</ulink> (free). ASP is said to be a slower and more cumbersome language than PHP, less stable as well. Some of the pros of ASP is that since it primarily uses VBScript it's relatively easy to pick up the language if you're already know how to program in Visual Basic. ASP support is also enabled by default in the IIS server making it easy to get up and running. The components built in ASP are really limited, so if you need to use "advanced" features like interacting with FTP servers, you need to buy additional components. </para> </answer> </qandaentry> <qandaentry id="faq.languages.aspconverter"> <question> <para>Is there an ASP to PHP converter?</para> </question> <answer> <para> Yes, the server-side <ulink url="&url.asp2php;">asp2php</ulink> is the one most often referred to as well as <ulink url="&url.asptranslator;">this client-side</ulink> option. </para> </answer> </qandaentry> <qandaentry id="faq.languages.coldfusion"> <question> <para>PHP vs. Cold Fusion?</para> </question> <answer> <para> PHP is commonly said to be faster and more efficient for complex programming tasks and trying out new ideas. PHP is generally referred to as more stable and less resource intensive as well. Cold Fusion has better error handling, database abstraction and date parsing although database abstraction is addressed in PHP 4. Another thing that is listed as one of Cold Fusion's strengths is its excellent search engine, but it has been mentioned that a search engine is not something that should be included in a web scripting language. PHP runs on almost every platform there is; Cold Fusion is only available on Win32, Solaris, Linux and HP/UX. Cold Fusion has a good IDE and is generally easier to get started with, whereas PHP initially requires more programming knowledge. Cold Fusion is designed with non-programmers in mind, while PHP is focused on programmers. </para> <para> A great summary by Michael J Sheldon on this topic has been posted to the PHP mailing list. A copy can be found <ulink url="&url.coldfusion.summary;">here</ulink>. </para> </answer> </qandaentry> <qandaentry id="faq.languages.perl"> <question> <para>PHP vs. Perl?</para> </question> <answer> <para> The biggest advantage of PHP over Perl is that PHP was designed for scripting for the web where Perl was designed to do a lot more and can because of this get very complicated. The flexibility / complexity of Perl makes it easier to write code that another author / coder has a hard time reading. PHP has a less confusing and stricter format without losing flexibility. PHP is easier to integrate into existing HTML than Perl. PHP has pretty much all the 'good' functionality of Perl: constructs, syntax and so on, without making it as complicated as Perl can be. Perl is a very tried and true language, it's been around since the late eighties, but PHP is maturing very quickly. </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/mailinglist.xml +++ phpdoc-es/faq/mailinglist.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.mailinglist"> <title>Mailing lists</title> <titleabbrev>Mailing lists</titleabbrev> <para> This section holds questions about how to get in touch with the PHP community. The best way is the mailing lists. </para> <qandaset> <qandaentry id="faq.mailinglist.isthere"> <question> <para>Are there any PHP mailing lists?</para> </question> <answer> <para> Of course! There are many mailing lists for several subjects. A whole list of mailing lists can be found on our <ulink url="&url.php.support;">Support</ulink> page. </para> <para> The most general mailing list is <literal>php-general</literal>. To subscribe, send mail to <ulink url="mailto:&url.ml.general.subscribe;">&url.ml.general.subscribe;</ulink>. You don't need to include anything special in the subject or body of the message. To unsubscribe, send mail to <ulink url="mailto:&url.ml.general.unsubscribe;">&url.ml.general.unsubscribe;</ulink>. </para> <para> You can also subscribe and unsubscribe using the web interface on our <ulink url="&url.php.support;">Support</ulink> page. </para> </answer> </qandaentry> <qandaentry id="faq.mailinglist.others"> <question> <para>Are there any other communities?</para> </question> <answer> <para> There are countless of them around the world. We have links for example to some IRC servers and foreign language mailing lists on our <ulink url="&url.php.support;">Support</ulink> page. </para> </answer> </qandaentry> <qandaentry id="faq.mailinglist.subscribing"> <question> <para> Help! I can't seem to subscribe/unsubscribe to/from one of the mailing lists! </para> </question> <answer> <para> If you have problems subscribing to or unsubscribing from the php-general mailing list, it may be because the mailing list software can't figure out the correct mailing address to use. If your email address was <literal>joeblow@example.com</literal>, you can send your subscription request to <literal>php-general-subscribe-joeblow=example.com@lists.php.net</literal>, or your unsubscription request to <literal>php-general-unsubscribe-joeblow=example.com@lists.php.net</literal>. Use similar addresses for the other mailing lists. </para> </answer> </qandaentry> <qandaentry id="faq.mailinglist.archive"> <question> <para>Is there an archive of the mailing lists anywhere?</para> </question> <answer> <para> Yes, you will find a list of archive sites on the <ulink url="&url.php.support;">Support</ulink> page. The mailing list articles are also archived as news messages. You can access the news server at <ulink url="&url.php.news;">&url.php.news;</ulink> with a news client. There is also an experimental web interface for the news server at <ulink url="&url.php.newsweb;">&url.php.newsweb;</ulink> </para> </answer> </qandaentry> <qandaentry id="faq.mailinglist.question"> <question> <para>What can I ask the mailing list?</para> </question> <answer> <para> Since PHP is growing more and more popular by the day the traffic has increased on the php-general mailing list and as of now the list gets about 150 to 200 posts a day. Because of this it is in everyones interest that you use the list as a last resort when you have looked everywhere else. </para> <para> Before you post to the list please have a look in this FAQ and the manual to see if you can find the help there. If there is nothing to be found there try out the mailing list archives (see above). If you're having problem with installing or configuring PHP please read through all included documentation and README's. If you still can't find any information that helps you out you're more than welcome to use the mailing list. </para> <para> Before asking questions, you may want to read the paper on <ulink url="&url.smart.questions;">How To Ask Questions The Smart Way</ulink> as this is a good idea for everyone. </para> </answer> </qandaentry> <qandaentry id="faq.mailinglist.guideline"> <question> <para>What information should I include when posting to the mailing list?</para> </question> <answer> <para> Posts like "I can't get PHP up and running! Help me! What is wrong?" are of absolutely no use to anyone. If you're having problems getting PHP up and running you must include what operating system you are running on, what version of PHP you're trying to set up, how you got it (pre-compiled, CVS, RPMs and so on), what you have done so far, where you got stuck and the exact error message. </para> <para> This goes for any other problem as well. You have to include information on what you have done, where you got stuck, what you're trying to do and, if applicable, exact error messages. If you're having problems with your source code you need to include the part of the code that isn't working. Do not include more code than necessary though! It makes the post hard to read and a lot of people might just skip it all together because of this. If you're unsure about how much information to include in the mail it's better that you include to much than to little. </para> <para> Another important thing to remember is to summarize your problem on the subject line. A subject like "HELP MEEEE!!!" or "What is the problem here?" will be ignored by the majority of the readers. </para> <para> And lastly, you're encouraged to read the paper on <ulink url="&url.smart.questions;">How To Ask Questions The Smart Way</ulink> as this will be a great help for everyone, especially yourself. </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/migration.xml +++ phpdoc-es/faq/migration.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.migration"> <title>Migrating from PHP 2 to PHP 3</title> <titleabbrev>Migrating from PHP 2 to PHP 3</titleabbrev> <para> PHP has already a long history behind him: Legendary PHP 1.0, PHP/FI, PHP 3.0 and PHP 4.0. </para> <qandaset> <qandaentry id="faq.migrating.phpfi"> <question> <para> Migrating from PHP 2 to PHP 3? </para> </question> <answer> <para> PHP/FI 2.0 is no longer supported. Please see <link linkend="migration">appropriate manual section</link> for information about migration from PHP/FI 2.0. </para> <para> If you are still working with PHP 2, we <emphasis>strongly</emphasis> recommend you to upgrade straight to PHP 4. </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/migration4.xml +++ phpdoc-es/faq/migration4.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.migration4"> <title>Migrating from PHP 3 to PHP 4</title> <titleabbrev>Migrating from PHP 3 to PHP 4</titleabbrev> <para> PHP has already a long history behind him : Legendary PHP 1.0, PHP/FI, PHP 3.0 and PHP 4.0. </para> <qandaset> <qandaentry id="faq.migration4.php34"> <question> <para> Migrating from PHP3 to PHP4 </para> </question> <answer> <para> PHP 4 was designed to be as compatible with earlier versions of PHP as possible and very little functionality was broken in the process. If you're really unsure about compatibility you should install PHP 4 in a test environment and run your scripts there. </para> <para> Also see the <link linkend="migration4">appropriate migration appendix</link> of this manual. </para> </answer> </qandaentry> <qandaentry id="faq.migration4.sessions"> <question> <para> Do sessions work in PHP 3? </para> </question> <answer> <para> Although <link linkend="ref.session">native session support</link> didn't exist in PHP 3, there are third-party applications that did (and still do) offer session functionality. The most common method was by using <ulink url="&url.phplib;">PHPLIB</ulink>. </para> </answer> </qandaentry> <qandaentry id="faq.migration4.incompatible"> <question> <para> Incompatible functions? </para> </question> <answer> <para> Since PHP 4 is basically a rewrite of the entire PHP engine there was very few functions that were altered and only then some of the more exotic ones. </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/misc.xml +++ phpdoc-es/faq/misc.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.misc"> <title>Miscellaneous Questions</title> <titleabbrev>Miscellaneous Questions</titleabbrev> <para> There can be some questions we can't put into other categories. Here you can find them. </para> <qandaset> <qandaentry id="faq.misc.popup"> <question> <para> Where did the pop-ups go on the website? Can I have the code for that? </para> </question> <answer> <para> The yellow pop-up windows on the old site were pretty cool, but were very difficult to maintain (since some companies seem to enjoy changing the way their browsers work with every new release). </para> <para> All the code for previous versions of the website is still available through CVS. Specifically, the last version of shared.inc (that had all the Javascript and DHTML to do the popups) is available <ulink url="&url.popup;">here</ulink>. </para> </answer> </qandaentry> <qandaentry id="faq.misc.bz2"> <question> <para> How can I handle the bz2 compressed manuals on Windows? </para> </question> <answer> <para> If you don't have an archiver-tool to handle bz2 files <ulink url="&url.bzip2;">download</ulink> the commandline tool from Redhat (please find further information below). </para> <para> If you would not like to use a command line tool, you can try free tools like <ulink url="&url.stuffit;">Stuffit Expander</ulink>, <ulink url="&url.ultimatezip;">UltimateZip</ulink>, <ulink url="&url.7zip;">7-Zip</ulink>, or <ulink url="&url.quickzip;">Quick Zip</ulink>. If you have tools like <ulink url="&url.winrar;">WinRAR</ulink> or <ulink url="&url.powerarchiver;">Power Archiver</ulink>, you can easily decompress the bz2 files with it. If you use Windows Commander, a bz2 plugin for that program is available freely from the <ulink url="&url.wincmd;">Windows Commander</ulink> site. </para> <para> The bzip2 commandline tool from Redhat: </para> <para> Win2k Sp2 users grab the latest version 1.0.2, all other Windows user should grab version 1.00. After downloading rename the executable to bzip2.exe. For convenience put it into a directory in your path, e.g. C:\Windows where C represents your windows installation drive. </para> <para> Note: lang stands for your language and x for the desired format, e.g.: pdf. To uncompress the php_manual_lang.x.bz2 follow these simple instructions: <itemizedlist> <listitem> <simpara>open a command prompt window</simpara> </listitem> <listitem> <simpara> cd to the folder where you stored the downloaded php_manual_lang.x.bz2 </simpara> </listitem> <listitem> <simpara> invoke bzip2 -d php_manual_lang.x.bz2, extracting php_manual_lang.x in the same folder </simpara> </listitem> </itemizedlist> </para> <para> In case you downloaded the php_manual_lang.tar.bz2 with many html-files in it, the procedure is the same. The only difference is that you got a file php_manual_lang.tar. The tar format is known to be treated with most common archivers on Windows like e.g. <ulink url="&url.winzip;">WinZip</ulink>. </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/obtaining.xml +++ phpdoc-es/faq/obtaining.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.obtaining"> <title>Obtaining PHP</title> <titleabbrev>Obtaining PHP</titleabbrev> <para> This section has details about PHP download locations, and OS issues. </para> <qandaset> <qandaentry id="faq.obtaining.where"> <question> <para>Where can I obtain PHP?</para> </question> <answer> <para> You can download PHP from any of the members of the PHP network of sites. These can be found at <ulink url="&url.php;">&url.php;</ulink>. You can also use anonymous CVS to get the absolute latest version of the source. For more information, go to <ulink url="&url.php.anoncvs;">&url.php.anoncvs;</ulink>. </para> </answer> </qandaentry> <qandaentry id="faq.obtaining.precompiled"> <question> <para>Are pre-compiled binary versions available?</para> </question> <answer> <para> We only distribute precompiled binaries for Windows systems, as we are not able to compile PHP for every major Linux/Unix platform with every extension combination. Also note, that many Linux distributions come with PHP built in these days. Windows binaries can be downloaded from our <ulink url="&url.php.downloads;">Downloads</ulink> page, for Linux binaries, please visit your distributions website. </para> </answer> </qandaentry> <qandaentry id="faq.obtaining.optional"> <question> <para> Where can I get libraries needed to compile some of the optional PHP extensions? </para> </question> <answer> <para> <note> <simpara> Those marked with * are not thread-safe libraries, and should not be used with PHP as a server module in the multi-threaded Windows web servers (IIS, Netscape). This does not matter in Unix environments, yet. </simpara> </note> </para> <para> <itemizedlist> <listitem> <simpara> <ulink url="&url.ldap.openldap.source;">LDAP (Unix)</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.ldap.mt;">LDAP* (Unix)</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.ldap.netscape.sdk;">LDAP (Unix/Win)</ulink> : Netscape Directory (LDAP) SDK 1.1. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.ldap.netscape.sdk;">free LDAP server</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.sleepycat;">Berkeley DB2 (Unix/Win)</ulink> : &url.sleepycat;. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.ucd-snmp;">SNMP* (Unix): </ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.gd;">GD* (Unix/Win)</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.msql;">mSQL* (Unix)</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.pgsql;">PostgreSQL (Unix)</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.imap;">IMAP* (Win/Unix)</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.sybase;">Sybase-CT* (Linux, libc5)</ulink> : Available locally. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.freetype;">FreeType (libttf):</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.zlib;">ZLib (Unix/Win32)</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.expat;">expat XML parser (Unix/Win32)</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.pdf;">PDFLib</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.mcrypt;">mcrypt</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.mhash;">mhash</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.t1lib;">t1lib</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.dmalloc;">dmalloc</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.aspell;">aspell</ulink>. </simpara> </listitem> <listitem> <simpara> <ulink url="&url.readline;">readline</ulink>. </simpara> </listitem> </itemizedlist> </para> </answer> </qandaentry> <qandaentry id="faq.obtaining.how"> <question> <para>How do I get these libraries to work?</para> </question> <answer> <para> You will need to follow instructions provided with the library. Some of these libraries are detected automatically when you run the 'configure' script of PHP (such as the GD library), and others you will have to enable using '<literal>--with-EXTENSION</literal>' options to '<literal>configure</literal>'. Run '<literal>configure --help</literal>' for a listing of these. </para> </answer> </qandaentry> <qandaentry id="faq.obtaining.compileNT"> <question> <para> I got the latest version of the PHP source code from the CVS repository on my Windows machine, what do I need to compile it? </para> </question> <answer> <para> First, you will need Microsoft Visual C++ v6 (v5 may do it also, but we do it with v6), and you will need some support files. See the manual section about <link linkend="install.windows.build">building PHP from source on Windows</link>. </para> </answer> </qandaentry> <qandaentry id="faq.obtaining.browscap"> <question> <para>Where do I find the Browser Capabilities File?</para> </question> <answer> <para> You can find a <filename>browscap.ini</filename> file at <ulink url="&url.browscap.download;">&url.browscap.download;</ulink>. </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-es/faq/using.xml +++ phpdoc-es/faq/using.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="faq.using"> <title>Using PHP</title> <titleabbrev>Using PHP</titleabbrev> <para> This section gathers many common errors that you may face while writing PHP scripts. </para> <qandaset> <qandaentry id="faq.using.anyform"> <question> <para> I would like to write a generic PHP script that can handle data coming from any form. How do I know which POST method variables are available? </para> </question> <answer> <para> PHP offers many <link linkend="language.variables.predefined"> predefined variables</link>, like the superglobal <varname> $_POST</varname>. You may loop through <varname>$_POST</varname> as it's an associate array of all POSTed values. For example, let's simply loop through it with <link linkend="control-structures.foreach"> foreach</link>, check for <function>empty</function> values, and print them out. <programlisting role="php"> <![CDATA[ <?php $empty = $post = array(); foreach ($_POST as $varname => $varvalue) { if (empty($varvalue)) { $empty[$varname] = $varvalue; } else { $post[$varname] = $varvalue; } } print "<pre>"; if (empty($empty)) { print "None of the POSTed values are empty, posted:\n"; var_dump($post); } else { print "We have " . count($empty) . " empty values\n"; print "Posted:\n"; var_dump($post); print "Empty:\n"; var_dump($empty); exit; } ?> ]]> </programlisting> </para> ¬e.superglobals; </answer> </qandaentry> <qandaentry id="faq.using.addslashes"> <question> <para> I need to convert all single-quotes (') to a backslash followed by a single-quote (\'). How can I do this with a regular expression? I'd also like to convert " to \" and \ to \\. </para> </question> <answer> <para> The function <function>addslashes</function> will do this. See also <function>mysql_escape_string</function>. You may also strip backslashes with <function>stripslashes</function>. </para> ¬e.magicquotes.gpc; </answer> </qandaentry> <qandaentry id="faq.using.stripslashes"> <question> <para> All my " turn into \" and my ' turn into \', how do I get rid of all these unwanted backslashes? How and why did they get there? </para> </question> <answer> <para> The PHP function <function>stripslashes</function> will strip those backslashes from your <type>string</type>. Most likely the backslashes magically exist because the PHP directive <link linkend="ini.magic-quotes-gpc">magic_quotes_gpc</link> is on. </para> ¬e.magicquotes.gpc; </answer> </qandaentry> <qandaentry id="faq.using.wrong-order"> <question> <para> When I do the following, the output is printed in the wrong order: <programlisting role="php"> <![CDATA[ <?php function myfunc($argument) { echo $argument + 10; } $variable = 10; echo "myfunc($variable) = " . myfunc($variable); ?> ]]> </programlisting> what's going on? </para> </question> <answer> <para> To be able to use the results of your function in an expression (such as concatenating it with other strings in the example above), you need to <function>return</function> the value, not <function>echo</function> it. </para> </answer> </qandaentry> <qandaentry id="faq.using.newlines"> <question> <para> Hey, what happened to my newlines? <programlisting role="php"> <![CDATA[ <pre> <?php echo "This should be the first line."; ?> <?php echo "This should show up after the new line above."; ?> </pre> ]]> </programlisting> </para> </question> <answer> <para> In PHP, the ending for a block of code is either "?>" or "?>\n" (where \n means a newline). So in the example above, the echoed sentences will be on one line, because PHP omits the newlines after the block ending. This means that you need to insert an extra newline after each block of PHP code to make it print out one newline. </para> <para> Why does PHP do this? Because when formatting normal HTML, this usually makes your life easier because you don't want that newline, but you'd have to create extremely long lines or otherwise make the raw page source unreadable to achieve that effect. </para> </answer> </qandaentry> <qandaentry id="faq.using.headers-sent"> <question> <para> I get the message 'Warning: Cannot send session cookie - headers already sent...' or 'Cannot add header information - headers already sent...'. </para> </question> <answer> <para> The functions <function>header</function>, <function>setcookie </function>, and the <link linkend="ref.session">session functions</link> need to add headers to the output stream but headers can only be sent before all other content. There can be no output before using these functions, output such as HTML. The function <function> headers_sent</function> will check if your script has already sent headers and see also the <link linkend="ref.outcontrol">Output Control functions</link>. </para> </answer> </qandaentry> <qandaentry id="faq.using.header"> <question> <para> I need to access information in the request header directly. How can I do this? </para> </question> <answer> <para> The <function>getallheaders</function> function will do this if you are running PHP as an Apache module. So, the following bit of code will show you all the request headers: <programlisting role="php"> <![CDATA[ <?php $headers = getallheaders(); foreach ($headers as $name => $content) { echo "headers[$name] = $content<br>\n"; } ?> ]]> </programlisting> </para> <para> See also <function>apache_lookup_uri</function>, <function>apache_response_headers</function>, and <function>fsockopen</function> </para> </answer> </qandaentry> <qandaentry id="faq.using.authentication"> <question> <para> When I try to use authentication with IIS I get 'No Input file specified'. </para> </question> <answer> <para> The security model of IIS is at fault here. This is a problem common to all CGI programs running under IIS. A workaround is to create a plain HTML file (not parsed by PHP) as the entry page into an authenticated directory. Then use a META tag to redirect to the PHP page, or have a link to the PHP page. PHP will then recognize the authentication correctly. With the ISAPI module, this is not a problem. This should not effect other NT web servers. For more information, see: <ulink url="&url.iis;">&url.iis;</ulink> and the manual section on <link linkend="features.http-auth">HTTP Authentication </link>. </para> </answer> </qandaentry> <qandaentry id="faq.using.netscape"> <question> <para> My PHP script works on IE and Lynx, but on Netscape some of my output is missing. When I do a "View Source" I see the content in IE but not in Netscape. </para> </question> <answer> <para> Netscape is more strict regarding html tags (such as tables) then IE. Running your html output through a html validator, such as <ulink url="&url.w3.validator;">validator.w3.org</ulink>, might be helpful. For example, a missing </table> might cause this. </para> <para> Also, both IE and Lynx ignore any NULs (<literal>\0</literal>) in the HTML stream, Netscape does not. The best way to check for this is to compile the <link linkend="features.commandline">command line</link> version of PHP (also known as the CGI version) and run your script from the command line. In *nix, pipe it through <literal>od -c</literal> and look for any <literal>\0</literal> characters. If you are on Windows you need to find an editor or some other program that lets you look at binary files. When Netscape sees a NUL in a file it will typically not output anything else on that line whereas both IE and Lynx will. </para> </answer> </qandaentry> <qandaentry id="faq.using.mixml"> <question> <para> How am I supposed to mix XML and PHP? It complains about my <?xml tags! </para> </question> <answer> <para> In order to embed <?xml straight into your PHP code, you'll have to turn off short tags by having the PHP directive <link linkend="ini.short-open-tag">short_open_tags</link> set to <literal>0</literal>. You cannot set this directive with <function> ini_set</function>. Regardless of <link linkend="ini.short-open-tag"> short_open_tags</link> being on or off, you can do something like: <literal><?php echo '<?xml'; ?></literal>. The default for this directive is on. </para> </answer> </qandaentry> <qandaentry id="faq.using.editor"> <question> <para> How can I use PHP with FrontPage or some other HTML editor that insists on moving my code around? </para> </question> <answer> <para> One of the easiest things to do is to enable using ASP tags in your PHP code. This allows you to use the ASP-style <% and %> code delimiters. Some of the popular HTML editors handle those more intelligently (for now). To enable the ASP-style tags, you need to set the <link linkend="ini.asp-tags">asp_tags</link> &php.ini; variable, or use the appropriate Apache directive. </para> </answer> </qandaentry> <qandaentry id="faq.using.variables"> <question> <para> Where can I find a complete list of variables are available to me in PHP? </para> </question> <answer> <para> Read the manual page on <link linkend="language.variables.predefined"> predefined variables</link> as it includes a partial list of predefined variables available to your script. A complete list of available variables (and much more information) can be seen by calling the <function>phpinfo</function> function. Be sure to read the manual section on <link linkend="language.variables.external">variables from outside of PHP</link> as it describes common scenerios for external variables, like from a HTML form, a Cookie, and the URL. </para> ¬e.registerglobals; </answer> </qandaentry> <qandaentry id="faq.using.cgi-vars"> <question> <para> I'm trying to access one of the standard CGI variables (such as $DOCUMENT_ROOT or $HTTP_REFERER) in a user-defined function, and it can't seem to find it. What's wrong? </para> </question> <answer> <para> It's important to realize that the PHP directive <link linkend="ini.register-globals">register_globals</link> also affects server and environment variables. When register_globals = off (the default is off since PHP 4.2.0), <varname>$DOCUMENT_ROOT</varname> will not exist. Instead, use <varname>$_SERVER['DOCUMENT_ROOT'] </varname>. If register_globals = on then the variables <varname>$DOCUMENT_ROOT</varname> and <varname>$GLOBALS['DOCUMENT_ROOT']</varname> will also exist. </para> <para> If you're sure register_globals = on and wonder why <varname>$DOCUMENT_ROOT</varname> isn't available inside functions, it's because these are like any other variables and would require <literal>global $DOCUMENT_ROOT</literal> inside the function. See also the manual page on <link linkend="language.variables.scope">variable scope</link>. It's preferred to code with register_globals = off. </para> ¬e.superglobals; </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->