Web Design Forums

PHP

Have questions about PHP? Ask them here and our experts will assist you before you know it! You can also find help in the documentation at PHP.net.

How to Connect Databse With PHP



Site of the Month Nominations
ENTER YOUR SITE NOW!

Reply
 
LinkBack Thread Tools
Old June 23 '09, 07:59 AM (#1)
Smith is offline
New Member!
 
Smith's Avatar
 
Join Date: June 2009
Posts: 2
Smith is an unknown quantity at this point
How to Connect Databse With PHP

Hi all this is Smith,
Can any one tell me how to connect a database with PHP. I need basic steps and program code to connect database in PHP.

Last edited by Smith; June 23 '09 at 08:16 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 23 '09, 03:39 PM (#2)
mlseim is offline
WDF Staff
 
mlseim's Avatar
 
Join Date: April 2004
Location: Cottage Grove, Minnesota
Posts: 3,401
mlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud of
Are you talking about MySQL specifically?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 23 '09, 06:05 PM (#3)
Danny[MLWA] is offline
WDF Regular
 
Danny[MLWA]'s Avatar
 
Join Date: June 2009
Location: Goldsboro, North Carolina, USA
Posts: 109
Danny[MLWA] is on a distinguished road
PHP I'm assuming MySQL...

PHP Code:
<?php
$host 
''//Hostname prob localhost
$user ''//Username for database
$pass ''//Password for database
$db ''//The Database Name...

// This will determine if the DB conection was successful....
if(connectMySQL($host,$user,$pass,$db) != FALSE)
    { 
// If its successful....
    
echo('Good to go!');
    } else { 
// If not, then halt the script but not before we let the user know.
    
echo('We got some problems!');
    die();
    }
////////
//
//
//
//
// Put your content here!
//
//
//
//
////////

// Put your functions at the bottom.
function conntectMySQL($host,$user,$pass,$db)
    { 
// This function combines the MySQL connect and DB select functions built-into php.
    
$link mysql_connect($host$user$pass);
    if(isset(
$link))
        {
        
$db_sel mysql_select_db($db);
        if(isset(
$db_sel))
            {
            return 
$db_sel;
            } else {
            return 
FALSE;
            }
        } else {
        return 
FALSE;
        }
    }

mysql_close(); // ALWYAS ALWAYS ALWAYS RUN THIS AT THE END OF THE SCRIPT.
?>

Last edited by Danny[MLWA]; June 23 '09 at 06:08 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 23 '09, 11:31 PM (#4)
Smith is offline
New Member!
 
Smith's Avatar
 
Join Date: June 2009
Posts: 2
Smith is an unknown quantity at this point
i asked about MySql only. Thank you
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 24 '09, 03:40 PM (#5)
mlseim is offline
WDF Staff
 
mlseim's Avatar
 
Join Date: April 2004
Location: Cottage Grove, Minnesota
Posts: 3,401
mlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud of
Smith ...
Danny has the correct answer to your question.
If that's not what you wanted, let us know.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 24 '09, 10:39 PM (#6)
smoseley is offline
WDF Moderator
 
smoseley's Avatar
 
Join Date: March 2003
Location: Miami, FL
Posts: 8,796
smoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud of
Research PEAR MDB2 - it's the best database connection component available for PHP. It's equivalent to Perl DBI.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

  Web Design Forums » Programming Help » PHP

Bookmarks


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

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Top 21 PHP Programming mistakes thexchord PHP 19 June 18 '10 02:20 PM
PHP Jobs Opportunity in Delhi, India Value One For Hire / Wanted 0 August 16 '04 06:30 AM
php vs. cfm gar598 PHP 1 April 2 '04 12:49 PM
PHP & Multiple databases Samibouni PHP 1 December 9 '03 06:37 PM
Basic PHP Uploads Tutorial thexchord Coding Articles & Tutorials 2 May 2 '02 08:28 PM

 
User Infomation
Your Avatar

Site Of The Month

Ticket Cake
Ticket Cake

Ticket Cake is a drupal based event ticketing platform. It features that ability to browse events and share them.

Nominate Your Site Now!

Advertisement
WolfCMS.org

Latest Articles
- by RickM
- by bfsog

Advertisement

Partner Links



All times are GMT -4. The time now is 02:45 AM.


WebDesignForums.net is Copyright © 2010 RikeMedia.

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163