XTREME-SOURCE
Search:

Go Back   XTREME-SOURCE > TUTORIALS > TUTORIAL ARCHIVE > TUTORIALS: WEB DESIGN
Shoutbox
Loading...


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 03-03-2006, 10:45 PM
kambodianboi's Avatar
Administrator
 
Join Date: Aug 2005
Posts: 3,223
Send a message via AIM to kambodianboi Send a message via Yahoo to kambodianboi
[PHP]Connecting to Database

Tools:
Apache WebServer
PHP
MySQL

Introduction:
In this tutorial, you will learn my way of connecting to a database. Also you will be able to INSERT, SELECT, and INTERACT with the database.

db.php
[php]
<?
$db_host = "localhost";
$db_uname = "root";
$db_upass = "";
$db_name = "db";

$connect = mysql_connect($db_host, $db_uname, $db_upass);

if(!$connect)
{
die("Could not connect to MySQL");
}

$s_db = mysql_select_db ($db_name);

if($s_db)
{
die("Could not select database");
}
?>
[/php]
What we just created is the backend code so you are able to connect to the database and create a open connection.

Now here we will process the SQL command to get the data from the DB.
process.php
[php]
<?php
require_once("db.php");

$query = "SELECT * FROM my_table";

if(!$result = mysql_query ($query))
{
die("Query failed");
}

$line = mysql_fetch_array($result);
?>
<pre>
<?=print_r($line);?>
</pre>
[/php]
Now that should display the database information from the table you select. I will update this tutorial with a proper information.
__________________
Xbox 360 - 2 Games - 2 Controllers - 120GB Elite - Dead
PS3 - 23 BD Games - 13 PSN Games - 9 Controllers - 320GB - Alive
Wii - 6 Games - 4 Wiimotes - Alive
PC - Overkill - 3DMark06 [15316]- God like :]
PC - New Build - 3DMark06 [32092]

Gaming Generations | XnogarD Production - Soon!!!
Reply With Quote
 
Old 12-28-2006, 02:33 AM
XS Enthusiast
 
Join Date: Dec 2006
Posts: 1

awesome
man. u should be proud.
Reply With Quote
 
Old 01-01-2007, 11:15 AM
XS Enthusiast
 
Join Date: Dec 2006
Posts: 2

okay i might sound stupid....but, how do i use that code?
Reply With Quote
 
Old 01-01-2007, 01:14 PM
kambodianboi's Avatar
Administrator
 
Join Date: Aug 2005
Posts: 3,223
Send a message via AIM to kambodianboi Send a message via Yahoo to kambodianboi

To use this, you need to have a PHP enabled server, you can download my Web Server installer in our download section. It will install everything you need to start a web server, and to start doing your own web programming aswell.
__________________
Xbox 360 - 2 Games - 2 Controllers - 120GB Elite - Dead
PS3 - 23 BD Games - 13 PSN Games - 9 Controllers - 320GB - Alive
Wii - 6 Games - 4 Wiimotes - Alive
PC - Overkill - 3DMark06 [15316]- God like :]
PC - New Build - 3DMark06 [32092]

Gaming Generations | XnogarD Production - Soon!!!
Reply With Quote
 
Old 04-07-2007, 02:42 PM
Jrnfl182
Guest
 
Posts: n/a

Nice Job Good Creation
Reply With Quote
 
Old 04-07-2007, 02:56 PM
Jrnfl182
Guest
 
Posts: n/a

Is the script you just provided used on this site for user accounts and passwords
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are Off
Refbacks are Off


vBulletin 3.7.1 ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0