|
![]() |
#1 |
Registered User
Join Date: Jan 2012
Location: USA
Posts: 5
|
How do i connect PHP MySQL to a Database?
__________________
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. |
![]() |
![]() |
![]() |
#2 |
Registered User
Join Date: Oct 2012
Posts: 33
|
first you need to create connection to the database
mysql_connect(servername,username,password); below is an example we store the connection in a variable ($con) for later use in the script. The "die" part will be executed if the connection fails: <?php $con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } // some code mysql_close($con); ?> mysql_close above will close the connection automatically when the script ends. |
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Importance of Php Development for Web Development | tech.biztech | Programming General | 35 | 11-22-2019 12:37 AM |
PHP/ apache problem | ncjbhd | PHP / mySQL | 0 | 10-17-2011 12:23 AM |
is it possible to make an php file trough a php code | ncjbhd | PHP / mySQL | 0 | 09-21-2011 11:49 PM |
Question about using php with dhtml tables | wryfhk22 | PHP / mySQL | 0 | 09-17-2011 01:59 AM |
Integrating PHP question | wryfhk22 | PHP / mySQL | 0 | 09-08-2011 02:52 AM |