Go Back   Gaming Gutter > Non-Gaming > Programming > Tutorials


Tutorials - Looking for programming tutorials to increase your knowledge? Do so here.

» Site Navigation
» Home
» FAQ
» Log in
User Name:

Password:

Not a member yet?
Register Now!
» Advertisement
» Recent Threads
Go to first new post Let us play pokemon!
Yesterday 03:57 AM
by Kyo
Last post by Kyo
Today 01:24 PM
82 Replies, 300 Views
Go to first new post Padooshiliana?
Today 12:46 PM
Last post by Snakebite
Today 01:23 PM
16 Replies, 17 Views
Go to first new post Religion.
07-30-2008 02:36 PM
Last post by ftw
Today 01:13 PM
59 Replies, 605 Views
Go to first new post So....I think I have...
Yesterday 07:49 PM
Last post by |G3|
Today 01:10 PM
18 Replies, 44 Views
Go to first new post WTF
Today 01:08 PM
Last post by Unregenerate Passion
Today 01:08 PM
0 Replies, 1 Views
Reply
 
LinkBack Thread Tools Display Modes

 Connecting to a MySQL Database with PHP
Old 10-18-2006, 03:40 PM   #1 (permalink)
Oosband
Guest

 
Posts: n/a
iTrader: / %
Connecting to a MySQL Database with PHP

Code:
<?php
$username = "db_username";
$password = "db_password";
$database = "db_name";
$hostname = "localhost";
$conn	 = mysql_connect("$hostname", "$username", "$password")
			or die("Invalid server or user.");
			
mysql_select_db("$database", $conn);
?>
The first group of variables determines the database which should
be connected to and which user has rights to connect to it.

Your connection variable, tells the script to either connect to the
database or die if no connection could be made.

Code:
$conn = mysql_connect("$hostname", "$username", "$password")
		   or die("Invalid server or user.");
---

The next php function selects the mysql database and allows you to
pull data from it.

Code:
mysql_select_db("$database", $conn);
  Reply With Quote
Reply

Bookmarks



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Signature That Connects To IPB MySQL Database Oosband Tutorials 0 10-18-2006 03:38 PM

Powered by vBadvanced CMPS v3.0 RC2

All times are GMT -7. The time now is 01:25 PM.


vBulletin skin developed by: eXtremepixels
The contents of this webpage are copyright © 2006-2008 GamingGutter.com. All Rights Reserved.

Page generated in 0.12164307 seconds (100.00% PHP - 0% MySQL) with 20 queries