Beginners Guide to PHP - Part 3: Database connections

PHP Programming Add comments

Hopefully by now, you’ve got your head around getting a PHP script to run by uploading it to a server and accessing its results through a web browser. If you stuck around for Part 2 in this series, you might even have dabbled with a Form or two. POSTing to a Form is one way of taking in information, doing something with it, and showing a result to the user. To take this much further, PHP can integrate very well with a database - this allows you, the PHP programmer, to display all kinds of data in limitless different ways to your website visitor. In this installment (Part 3), we’re going to take a look at hooking up a PHP script to a MySQL database.

First things first - does your website host support MySQL?
If your web host gives you access to a “control panel”, have a look around for a section on Databases. There’s a pretty solid chance that if you can run PHP scripts and you have a Control Panel to configure your webhost & email, that you will have at least limited access to a MySQL database. If you don’t have a Control Panel, or you cannot see anything about databases in it, email your provider and ask them the following:
“I wish to run a PHP script that requires a MySQL database - do you offer MySQL databases on my domain? If so, can you let me know what connection port/socket/string I should use (e.g. “localhost”?), and what username/password.”

Setting up your database and tables
ARTICLE COMPLETES SOON…

Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • digg
  • Reddit
  • del.icio.us
  • YahooMyWeb
  • Fark

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in

Bad Behavior has blocked 111 access attempts in the last 7 days.