freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內容

畢業(yè)設計——基于php的留言板的設計與實現-資料下載頁

2025-06-23 04:02本頁面
  

【正文】 iltin database functions. We’ll 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 es from a process called abstraction. In programming interfaces, abstraction simplifies a plex interaction. It works byremoving any nonessential parts of the interaction, allowing you to concentrate on the important parts. PEAR’s DB classes are one such database interface abstraction. The information you need to log into a database is reduced to the bare minimum. This standard format allows you to interact with MySQL, as well as other databases using the same functions. Similarly, other MySQLspecific functions are replaced with generic ones that know how to talk to many databases. For example, the MySQLspecific connect function is:mysql_connect($db_host, $db_username, $db_password)。versus PEAR’s DB connect function:$connection = DB::connect(mysql://$db_username:$db_password@$db_host/$db_database)。The same basic information is present in both mands, but the PEAR function also specifies the type of databases to which to connect. You can connect to MySQL or other supported databases. We’ll discuss both connection methods in detail.In this chapter, you’ll 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, whether using the mysql mandline 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.We’ll walk through each of these steps for both plain PHP and PEAR functions.ResourcesWhen connecting to a MySQL database, 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 query’s result set. You’ll 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. It’s quite simple, and we’ll begin shortly with examples, but we should talk briefly about what actually happens. 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, we’ll need the same pieces of information 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 mandline client.Figure 91 shows how the steps of the database interaction relate to the two types of resources. Building the SELECT statement happens before the third function call, but it is not shown. It’s done with plain PHP code, not a MySQLspecific PHP function.Figure 91. The interaction between functions and resources when using the databaseIncluding Database Login DetailsYou’re going to create a file to hold the information for logging into MySQL. Storing this information in a file you include is remended. 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 don’t have to worry about 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.Let’s call this file and place it in the same directory as your other PHP files. The file is represented in Example 91.Example 91. A template for setting database login settings?php$db_host=39。hostname of database server39。$db_database=39。database name39。$db_username=39。username39。$db_password=39。password39。?In Example 92, we create this file to use a database on the same machine as the web server. We assign it a database name, username, and password.?php$db_host=39。localhost39。$db_database=39。test39。$db_username=39。test39。$db_password=39。yourpass39。?Figure 92 illustrates how you’re going to use this file with other PHP files. You’regoing to continue using the database that you started to set up in Chapter 7.Figure 92. Reusing the login details in multiple filesExample 93. The SQL to recreate the test objects (continued)DROP TABLE IF EXISTS books。CREATE TABLE books (title_id int(11) NOT NULL auto_increment,title varchar(150) default NULL,pages int(11) default NULL,PRIMARY KEY (title_id)) ENGINE=MyISAM DEFAULT CHARSET=latin1。 Dumping data for table booksINSERT INTO books VALUES (1,39。Linux in a Nutshell39。,476),(2,39。Classic Shell Scripting39。,256)。 Table structure for table purchasesDROP TABLE IF EXISTS purchases。CREATE TABLE purchases ( id int(11) NOT NULL auto_increment, user varchar(10) default NULL, title varchar(150) default NULL, day date default NULL,PRIMARY KEY (id)) ENGINE=MyISAM DEFAULT CHARSET=latin1。 Dumping data for table purchasesLOCK TABLES purchases WRITE。INSERT INTO purchases VALUES (1,39。Mdavis39。,39。Regular Expression Pocket Reference39。,39。2005021539。),(2,39。Mdavis39。,39。JavaScript amp。 DHTML Cookbook39。,39。2005021039。)。If you didn’t create the tables in Chapter 8, the code in Example 93 can be saved as and run from the mand prompt with the following syntax:mysql u username ppassword D database_name Using the values from the examples, it bees:mysql u test pyourpass D test The database is called test, and it consists of three tables called books, authors,
點擊復制文檔內容
數學相關推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1