Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - Programming » SQL Anywhere PHP API » Installing and configuring SQL Anywhere PHP

Choosing which PHP module to use Next Page

Installing the PHP module on Windows


To use the SQL Anywhere PHP module on Windows, you must copy the DLL from the SQL Anywhere installation directory and add it to your PHP installation. Optionally, you can add an entry to your PHP initialization file to load the module, so you do not need to load it manually in each script.

To install the PHP module on Windows
  1. Locate the php.ini file for your PHP installation, and open it in a text editor. Locate the line that specifies the location of the extension_dir directory.

  2. Copy the file phpX_sqlanywhere10.dll, where X is the PHP version number from the win32 subdirectory of your SQL Anywhere installation, to the directory specified by the extension_dir entry in the php.ini file.

    Note

    If your version of PHP is more recent than the SQL Anywhere PHP modules provided by SQL Anywhere, try using the most recent module provided. For example, if you installed PHP 5.1.6, and the most recent SQL Anywhere PHP module is php-5.1.2_sqlanywhere10.dll, use php-5.1.2_sqlanywhere10.dll.

  3. Add the following line to the Dynamic Extensions section of the php.ini file to load the SQL Anywhere PHP driver automatically.

    extension=php-X_sqlanywhere10.dll

    where X reflects the version number of the SQL Anywhere PHP module copied in the previous step.

    An alternative to automatically loading the PHP driver is to load it manually in each script that requires it. See Configuring the SQL Anywhere PHP module.

  4. At a command prompt, enter the following command to start the SQL Anywhere sample database.

    dbeng10 demo.db

    You may have to specify the location of the SQL Anywhere sample database on the command line. For example:

    dbeng10 "C:\Documents and Settings\All Users\Documents\SQL Anywhere 10\Samples\demo.db"

    The command starts a database server with a server name of demo. If you start the server from the Windows Start menu, it has a server name of demo10, which is not compatible with the PHP samples in the SQL Anywhere documentation.

  5. At a command prompt, change to the src\php\examples subdirectory of your SQL Anywhere installation, and enter the following command:

    php connect.php

    The message Connected successfully should appear. If the PHP command is not recognized, verify that PHP is in your path.

  6. When you are done, stop the SQL Anywhere database server by clicking Shutdown in the Server Messages window.

For more information, see Creating PHP test pages.