访问其他页面中的MySQL连接语句[重复]

Possible Duplicate:
Using same MySQL Connection in different PHP pages

This is completely new to me, as it stands i have my connect statements on each page in my PHP system. is there a way that i can store this in another, dedicated file and call on this in each page as opposed to including the hard code in each PHP file? could anyone point me in the right direction for tutorials or explain how this works?

Thanks

Put the connection information in a file, and use include in all the other pages.

  • Make sure you use .php as extension for the file you're gonna include.
  • For security reasons, it is advised to keep the file out of your webroot (one map up is better).
  • In case you haven't familiarized yourself with it already, try looking into PDO or MySQLi instead of the usual mysql_ functions.

include
include_once
require
require_once

  • The include statement includes and evaluates the specified file.
  • require is identical to include except upon failure it will also produce a fatal E_COMPILE_ERROR level error.