No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

Rechercher une fonction PHP

dbx_connect

(PHP 4 >= 4.0.6, PHP 5 < 5.1.0, PECL dbx >= 1.1.0)

dbx_connectOpen a connection/database

Description

dbx_connect ( mixed $module , string $host , string $database , string $username , string $password [, int $persistent ] ) : object

Opens a connection to a database.

PHP: dbx_connect - Manual Home of Manuel PHP  Contents Haut

Parameters

module

The module parameter can be either a string or a constant, though the latter form is preferred. The possible values are given below, but keep in mind that they only work if the module is actually loaded.

  • DBX_MYSQL or "mysql"
  • DBX_ODBC or "odbc"
  • DBX_PGSQL or "pgsql"
  • DBX_MSSQL or "mssql"
  • DBX_FBSQL or "fbsql"
  • DBX_SYBASECT or "sybase_ct"
  • DBX_OCI8 or "oci8"
  • DBX_SQLITE or "sqlite"

host

The SQL server host

database

The database name

username

The username

password

The password

persistent

The persistent parameter can be set to DBX_PERSISTENT, if so, a persistent connection will be created.

The host, database, username and password parameters are expected, but not always used depending on the connect functions for the abstracted module.

PHP: dbx_connect - Manual Home of Manuel PHP  Contents Haut

Return Values

Returns an object on success, FALSE on error. If a connection has been made but the database could not be selected, the connection is closed and FALSE is returned.

The returned object has three properties:

database
It is the name of the currently selected database.
handle

It is a valid handle for the connected database, and as such it can be used in module-specific functions (if required).

<?php
$link 
dbx_connect(DBX_MYSQL"localhost""db""username""password");
mysql_close($link->handle); // dbx_close($link) would be better here
?>

module
It is used internally by dbx only, and is actually the module number mentioned above.

PHP: dbx_connect - Manual Home of Manuel PHP  Contents Haut

Examples

Example #1 dbx_connect() example

<?php
$link 
dbx_connect(DBX_ODBC"""db""username""password"DBX_PERSISTENT)
    or die(
"Could not connect");

echo 
"Connected successfully";
dbx_close($link);
?>

PHP: dbx_connect - Manual Home of Manuel PHP  Contents Haut

Notes

Note:

Always refer to the module-specific documentation as well.

PHP: dbx_connect - Manual Home of Manuel PHP  Contents Haut

See Also

Find a PHP function

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-dbx-connect.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:fr Manuel PHP : http://php.net

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.

Contents Haut