TAILIEUCHUNG - PHP and MySQL Web Development - P54

PHP and MySQL Web Development - P54: PHP and MySQL Web Development teaches the reader to develop dynamic, secure, commercial Web sites. Using the same accessible, popular teaching style of the first edition, this best-selling book has been updated to reflect the rapidly changing landscape of MySQL and PHP. | Using a Generic Database Interface PEAR DB 237 is a standard for connections to databases. It has the most limited functionality of any of the function sets for fairly obvious reasons. If you have to be compatible with everything you can t exploit the special features of anything. In addition to the libraries that come with PHP database abstraction classes such as Metabase or PEAR DB are available that allow you to use the same function names for each different type of database. Using a Generic Database Interface PEAR DB We will look at a brief example using the PEAR DB abstraction layer. This is one of the core components of PEAR and probably the most widely used of all the PEAR components. If you have PEAR installed then you should already have DB. If not please refer to the PEAR Installation section in Appendix A. For comparative purposes let s look at how we would have written our search results script differently using DB. Listing Retrieves Search Results from our MySQL Database and Formats Them for Display html head title Book-O-Rama Search Results title head body h1 Book-O-Rama Search Results h1 php create short variable names searchtype HTTP_POST_VARS searchtype searchterm HTTP_POST_VARS searchterm searchterm trim searchterm if searchtype searchterm echo You have not entered search details. Please go back and try again. exit searchtype addslashes searchtype searchterm addslashes searchterm set up for using PEAR DB require user bookorama pass bookorama123 host localhost 238 Chapter 10 Accessing Your MySQL Database from the Web with PHP Listing Continued db_name books set up universal connection string or DSN dsn mysql user pass@ host db_name connect to database db DB connect dsn true check if connection worked if DB isError db echo db- getMessage exit perform query query select from books where . searchtype. like . searchterm. result db- query query check that result was ok if DB isError result echo db- getMessage exit .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.