Web software for add deleting updating data

In this chapter, you’ll learn how to take information stored in a My SQL database and display it on a web page for all to see.

So far, you’ve installed and learned the basics of My SQL, a relational database engine, and PHP, a server-side scripting language.

You must therefore follow up your variable that contains the My SQL link identifier to tell the function which database connection to use.

This function returns true when it's successful and false if an error occurs.

Since we intend to make use of the connection, we should hold onto this value.

Here’s an example of how we might connect to our My SQL server: As described above, the values of the three function parameters may differ for your My SQL server; at the very least, you’ll need to substitute in the root password you established for your My SQL server.

As shown in the figure above, the PHP scripting language is the go-between that speaks both languages.

If PHP is unable to connect to your My SQL server, or if the username and password you provided are incorrect, you'll instead see a similar screen to that in the figure below.

Just so it’s clear and fresh in your mind, this is what will happen when a person visits a page on your database driven web site: Before you can retrieve content out of your My SQL database for inclusion in a web page, you must know how to establish a connection to My SQL from inside a PHP script.

Back in Chapter 2: Introducing My SQL, you used a program called mysql that allowed you to make such a connection from the command prompt.

In such cases, the is the first example in this book of a function that can be called with no parameters.

When called this way, all this function does is cause PHP to stop executing the script at this point.

Leave a Reply