php毕业设计外文翻译

上传人:206****923 文档编号:90603795 上传时间:2019-06-13 格式:DOC 页数:13 大小:69.04KB
返回 下载 相关 举报
php毕业设计外文翻译_第1页
第1页 / 共13页
php毕业设计外文翻译_第2页
第2页 / 共13页
php毕业设计外文翻译_第3页
第3页 / 共13页
php毕业设计外文翻译_第4页
第4页 / 共13页
php毕业设计外文翻译_第5页
第5页 / 共13页
点击查看更多>>
资源描述

《php毕业设计外文翻译》由会员分享,可在线阅读,更多相关《php毕业设计外文翻译(13页珍藏版)》请在金锄头文库上搜索。

1、原文:Getting PHP to Talk to MySQlNow that youre comfortable using the MySQL client tools to manipulate data in the database, you can begin using PHP to display and modify data from the database. PHP has standard functions for working with the database.First, were going to discuss PHPs built-in databas

2、e functions. Well also show you how to use the The PHP Extension and Application Repository (PEAR) databasefunctions that provide the ability to use the same functions to access any supported database. This type of flexibility comes from a process called abstraction. In programming interfaces, abstr

3、action simplifies a complex interaction. It works byremoving any nonessential parts of the interaction, allowing you to concentrate on the important parts. PEARs DB classes are one such database interface abstraction. The information you need to log into a database is reduced to the bare minimum. Th

4、is standard format allows you to interact with MySQL, as well as other databases using the same functions. Similarly, other MySQL-specific functions are replaced with generic ones that know how to talk to many databases. For example, the MySQL-specific connect function is:mysql_connect($db_host, $db

5、_username, $db_password);versus PEARs DB connect function:$connection = DB:connect(mysql:/$db_username:$db_password$db_host/$db_database);The same basic information is present in both commands, but the PEAR function also specifies the type of databases to which to connect. You can connect to MySQL o

6、r other supported databases. Well discuss both connection methods in detail.In this chapter, youll learn how to connect to a MySQL server fromPHP, how to use PHP to access and retrieve stored data, and how to correctly display information to the user.The ProcessThe basic steps of performing a query,

7、 whether using the mysql command-line tool or PHP, are the same: Connect to the database. Select the database to use. Build a SELECT statement. Perform the query. Display the results.Well walk through each of these steps for both plain PHP and PEAR functions.ResourcesWhen connecting to a MySQL datab

8、ase, you will use two new resources. The first is the link identifier that holds all of the information necessary to connect to the database for an active connection. The other resource is the results resource. It contains all information required to retrieve results from an active database querys r

9、esult set. Youll be creating and assigning both resources in this chapter.Querying the Database with PHP FunctionsIn this section, we introduce how to connect to a MySQL database with PHP. Its quite simple, and well begin shortly with examples, but we should talk briefly about what actually happens.

10、 When you try connecting to a MySQL database, the MySQL server authenticates you based on your username and password. PHP handles connectingto the database for you, and it allows you to start performing queries and gathering data immediately.As in Chapter 8, well need the same pieces of information

11、to connect to the database: The IP address of the database server The name of the database The username The passwordBefore moving on, make sure you can log into your database using the MySQL command-line client.Figure 9-1 shows how the steps of the database interaction relate to the two types of res

12、ources. Building the SELECT statement happens before the third function call, but it is not shown. Its done with plain PHP code, not a MySQL-specific PHP function.Figure 9-1. The interaction between functions and resources when using the databaseIncluding Database Login DetailsYoure going to create

13、a file to hold the information for logging into MySQL. Storing this information in a file you include is recommended. If you change the database password, there is only one place that you need to change it, regardless of how manyPHP files you have that access the database.You dont have to worry abou

14、t anyone directly viewing the file and getting your database login details. The file, if requested by itself, is processed as a PHP file and returns a blank page.Troubleshooting connection errorsOne error you may get is:Fatal error: Call to undefined function mysql_connect( ) in C:Program FilesApach

15、eSoftware FoundationApache2.2htdocsdb_test.php on line 4This error occurs because PHP 5.x for Windows was downloaded, and MySQL support was not included by default. To fix this error, copy the php_mysql.dll file from the ext/ directory of the PHP ZIP file to C:php, and then C:WINDOWSphp.ini.Make sur

16、e there are two lines that are not commented out by a semicolon (;) at the beginning of the line like these:extension_dir = c:/PHP/ext/extension=php_mysql.dllThis will change the extension to include the directory to C:/php and include the MySQL extension, respectively. You can use the Search function of your text editor to check whether the lines are alr

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 中学教育 > 其它中学文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号