How to connect to a MySQL database using PHP

you have a database. To connect to the database of your PHP program and do some amazing things. Easy !

Make sure you have a database. Record the database name, user name and password. The host name is normally “localhost”, however, some hosting companies (such as GoDaddy) will give a host name, so you may need to do a little research to find it. A note on the following steps: eHow not as line breaks, so that the text of the code, see the tips below to create your connection .

file. This should be separated from its other files, and it should be obvious - or connect.php setup.php. You can create in any text editor (even Notepad), but using an editor like PHP Eclipse is better because it will tell you if you have an error .

First, we need to set variables our connection. This will make it easier to change what happens later. I like this syntax, because everything lines up very well .

Then we will tell you what to do PHP. The first will say that to connect to the host. We are using the mysql_connect (), you need to know the host, and then the user name, password. They tell us that reflect the errors that you may receive when you try to connect .

After that, we say that our database by selecting mysql_select_db () function. We have already connected to the host, so you just have to say that the database we want to play with .

For testing purposes, which must be done after you connect. Once you have established what is, in fact, the connection, you must delete this section. Only echo or print something to let you know that worked.

Featured Links:

Google Payload
Proven Money Maker At $9,547 A Day.
Burn The Fat Feed The Muscle
Burn The Fat - Top Selling Fat Loss Ebook Since 2003.
Save My Marriage Today!
Have You Ever Stayed Awake at Night Stressing About Whether or Not Your Marriage Will Last ... And What You Can Possibly Do to Save It?
Ultra Hot* SpywareBot: #1 AntiSpyware
Scan your computer for hidden AdWare and Spyware, Remove them permanently.
Top Movie Downloads
Join the Internet revolution and start downloading free movies and more!
Get Google Pay-Per-Click Ads Free!
Internet Marketer Gets $87 Million in Google Pay-Per-Click Ads FREE! ... And Makes Over $314 Million as a Result! ...And Now He's Going to Give You This Same Secret for Next to Nothing!
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • StumbleUpon
  • TwitThis

Leave a comment

You must be logged in to post a comment.