Preview

PHP 04 mySQL

Powerful Essays
Open Document
Open Document
2601 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
PHP 04 mySQL
Manipulating MySQL
Databases with PHP

Objectives







Connect to MySQL from PHP
Learn how to handle MySQL errors
Execute SQL statements with PHP
Use PHP to work with MySQL databases and tables Use PHP to manipulate database records

PHP and mySQL

2

PHP Overview






PHP has the ability to access and manipulate any database that is ODBC compliant
PHP includes functionality that allows you to work directly with different types of databases, without going through ODBC
PHP supports SQLite, database abstraction layer functions, and PEAR DB

PHP and mySQL

3

Enabling MySQL Support in
PHP


On UNIX/Linux systems:




Configure PHP to use the mysqli extension by specifying the --with-mysqli parameter when you run the configure command during installation On Windows:




PHP and mySQL

Copy the files libmysql.dll and php_mysqli.dll to the installation directory
Edit the php.ini configuration file and enable the extension=php_mysqli.dll directive

4

Opening and Closing a MySQL
Connection






Open a connection to a MySQL database server with the mysqli_connect() function
The mysqli_connect() function returns a positive integer if it connects to the database successfully or false if it does not
Assign the return value from the mysqli_connect() function to a variable that you can use to access the database in your script

PHP and mySQL

5

Opening and Closing a MySQL
Connection (continued)


The syntax for the mysqli_connect() function is:
$connection = mysqli_connect("host"[, "user ", "password",
"database"])







The host argument specifies the host name where your MySQL database server is installed
The user and password arguments specify a
MySQL account name and password
The database argument selects a database with which to work

PHP and mySQL

6

Opening and Closing a MySQL
Connection (continued)
Table 9-1 MySQL server information functions

PHP and mySQL

7

Opening and Closing a MySQL
Connection (continued)

Figure 9-1

You May Also Find These Documents Helpful

  • Good Essays

    Wikimedia Foundation, I. (2014, 10 13). From Wikipedia, the free encyclopedia. Retrieved from From Wikipedia, the free encyclopedia: http://en.wikipedia.org/wiki/MySQL…

    • 664 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Several versions of MySQL are available, and most are available in several distribution formats. We choose a production (stable) release:…

    • 933 Words
    • 4 Pages
    Good Essays
  • Powerful Essays

    A database language must enable the user to perform complex queries designed to transform the raw data into useful information.…

    • 1917 Words
    • 8 Pages
    Powerful Essays
  • Good Essays

    Assingment 1

    • 663 Words
    • 3 Pages

    A database system is made up of five components and they are Hardware, Software, People, Procedures and data.…

    • 663 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    SQL Queries

    • 423 Words
    • 2 Pages

    Given the table information above, if you were asked to create an Access query that showed the Student Name and Grade for all students taking a class in Room H201, what tables would you need and how would you link them together?…

    • 423 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Db Forum I-Theo104

    • 308 Words
    • 2 Pages

    Many ask, “Is the Bible the Word of God?” Dr. Elmer Towns compiled 10 arguments that the Bible is in fact the Word of God. Choosing one of these 10 persuading arguments was a daunting task as they are all equally convincing in my eyes. The extraordinary claims that the Bible is from God intrigued me the most.…

    • 308 Words
    • 2 Pages
    Good Essays
  • Better Essays

    Database Design

    • 1196 Words
    • 5 Pages

    “A database is a structured collection of records or data that is stored in a computer system. In order for a database to be truly functional, it must not only store large amounts of record, but also be able to access those records fast and efficiently. In addition, new information and changes should also be easy to input.” (tech-faq.com) To be useful over a long term the database should be able to store all the records necessary for the business to function as well as be able to get all of this information back in case of a system failure or a crash. If all the information is loss a business could go bankrupt so the database is a fail safe for all the information the company has.…

    • 1196 Words
    • 5 Pages
    Better Essays
  • Satisfactory Essays

    database mgnt

    • 730 Words
    • 3 Pages

    5. Identify and discuss the serious data redundancy problems exhibited by the file structure shown in Figure P1.5.…

    • 730 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Database Sql Server

    • 328 Words
    • 2 Pages

    Data mining uses business intelligence tools and techniques on a variety of data sources brought together in a data warehouses. true…

    • 328 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Sql Database Language

    • 1101 Words
    • 5 Pages

    Get the offering, the course number, and the course description of SUMMER 2010 offerings without an assigned instructor.…

    • 1101 Words
    • 5 Pages
    Satisfactory Essays
  • Powerful Essays

    To end up with a good ‘relational database’ application, you need to ask: Do I actually need one? If so, how far do you want to take it? By this I mean, is this to be a simple database to store information about only one, or very few, related entities (i.e. a list of people who attended a certain event, and how they came to hear about the event) which are not likely to change; or a permanent and well used application with several different entities (i.e. Staff, Departments, Branches, SalesFigures for various periods/staff members/departments) which are constantly changing. If the forma is the case, a simple ‘Flat File’ database is all that is required. There are several basic database products on the market that will fully service this requirement but all that is needed is a table in MS Word for Windows or a basic Spreadsheet application, such as MS Excel. If the later is the case, then a Relational Database is needed. Although there are many products on the market, they have several common features and all use some form of SQL (Structured Query Language) to build, edit and query the database.…

    • 2594 Words
    • 11 Pages
    Powerful Essays
  • Good Essays

    3. Using phpmyadmin create a new database and name it appropriately. The name of this database is important…

    • 838 Words
    • 4 Pages
    Good Essays
  • Powerful Essays

    Working with Database Design

    • 2266 Words
    • 10 Pages

    Various other aspects and needed requirements are to be introduced and implemented into Jim and Tim’s new ACCESS™2010® Relational Database Management Systems from concepts, theories, analysis, import/export, referential integrity, primary/foreign/ non keys, data-modeling, and normalization. Needs to assure value, structure, relationship, and integrity are implemented in the relational database management systems (RDBMS) for the explicit users ability to flawless query information/data which allows by logical authentication to request, add, modify, and view correct, understandable intellectual organizational RDBS while using the export and import functions of ACCESS™2010®, EXCEL 2010, and MS SQL SERVER. One issue with almost all software (any type) is because humans write the code for software and on the other hand other humans reverse engineer written software finding weakness, and design script or bot code, which will become a threat agent in a form of a Trojan-horse, viruses, Dos, DDoS, and other forms of illegal hacking to steal intellectual data. A suggestion is using a specific tool called CAPTCHA “(Completely Automated Public Turing Test to tell Computers and Humans apart),” also known as “Gausebeck-Levchin Test.” This is to create anti-fraud detection, which prevents a script or a bot from being able to complete authentication. Although, this tool used in Pay-Pal transactions, its use for on-line of other types of internet web transactions to assure a live human interaction. This tool implementation into the accounting section between customers to RoboBoys and even between Jim, Tim, and vendors, which helps prevent the…

    • 2266 Words
    • 10 Pages
    Powerful Essays
  • Good Essays

    Database Design

    • 418 Words
    • 2 Pages

    Before you use Microsoft Access to actually build the tables, forms, and other objects that will make up your database, it is important to take time to design your database. A good database design is the keystone to creating a database that foes what you want it to do effectively, accurately, and efficiently.…

    • 418 Words
    • 2 Pages
    Good Essays
  • Better Essays

    Database Design

    • 1126 Words
    • 5 Pages

    Currently a school uses a non-computerised database system to store the following information about its students: roll class, surname, first name, guardian 's name, address, student 's date of birth, gender, sport house, emergency-contact telephone number, mailing name, list of subjects offered, and subjects in which the student is enrolled. The system takes up a large amount of space, has many duplicated entries some of these with mistakes and it is time consuming to search. The school intends to introduce a relational-database management system to overcome these problems.…

    • 1126 Words
    • 5 Pages
    Better Essays

Related Topics