mysql连接文件_PHP中MySQL连接文件快捷方式

mysql连接文件

Many website owners use PHP to enhance the capabilities of their webpages. When they combine PHP with the open-source relational database MySQL, the list of capabilities grows immensely. They can establish login credentials, conduct user surveys, set and access cookies and sessions, rotate banner ads on their site, host user forums, and open online stores, among many other features that are not possible without a database.

许多网站所有者使用PHP来增强其网页的功能。 当他们将PHP与开放源代码关系数据库MySQL结合使用时,功能列表将大大增加。 他们可以建立登录凭据,进行用户调查,设置和访问Cookie和会话,在其站点上旋转横幅广告,托管用户论坛以及打开在线商店,以及许多其他功能 ,而这些功能没有数据库就无法实现。

MySQL and PHP are compatible products and are frequently used together by website owners. The MySQL code can be included directly in the PHP script. Both are located on your web server, and most web servers support them. The server-side location provides reliable security for the data your website uses.

MySQL和PHP是兼容的产品,网站所有者经常一起使用。 MySQL代码可以直接包含在PHP脚本中。 两者都位于您的Web服务器上,并且大多数Web服务器都支持它们。 服务器端位置可为您的网站使用的数据提供可靠的安全性。

将多个网页连接到一个MySQL数据库 ( Connecting Multiple Webpages to One MySQL Database )

If you have a small website, you probably don't mind typing your MySQL database connection code into the PHP script for a few pages. However, if your website is large and many of the pages require access to your MySQL database, you can save time with a shortcut. Put the MySQL connection code in a separate file and then call the saved file where you need it.

如果您的网站很小,则可能不介意将MySQL数据库连接代码键入PHP脚本几页。 但是,如果您的网站很大,并且许多页面都需要访问MySQL数据库 ,则可以使用快捷方式节省时间。 将MySQL连接代码放在单独的文件中,然后在需要的地方调用保存的文件。

For example, use the SQL code below in a PHP script to log in to your MySQL database. Save this code in a file called datalogin.php.

例如,在PHP脚本中使用下面的SQL代码登录到MySQL数据库。 将此代码保存在名为datalogin.php的文件中。

Now, whenever you need to connect one of your webpages to the database, you include this line in PHP in the file for that page:

现在,每当您需要将一个网页连接到数据库时,就可以在该页面的文件中PHP中包含以下行:

When your pages connect to the database, they can read from it or write information to it. Now that you can call MySQL, use it to set up an address book or a hit counter for your website. 

当页面连接到数据库时,它们可以从中读取或向其中写入信息。 现在您可以调用MySQL,使用它为您的网站设置地址簿或点击计数器。

翻译自: https://www.thoughtco.com/mysql-connect-files-in-php-2694111

mysql连接文件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值