|
|
|
|||
|
Web Development
|
| Discuss the technologies surrounding the world wide web. |
|
||||||
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
(#1 (permalink))
|
|
n00bie
![]() Posts: 19
Join Date: Jul 2008
Last Online: 12-27-2009 01:04 PM Reputation:
![]() User is Offline
|
PHP - Database connection class -
12-27-2008, 05:20 PM
Hi there. Today I'm going to learn you about Mysql Database connection using a class.
Requirements - PHP5 Server (not 4 )- Basic knowledge of PHP (See my other tutorial) ![]() Normally you would connect to a mysql database like this: PHP Code:
So you can do this with a class and a config file (config.php). For example: config.php PHP Code:
PHP Code:
PHP Code:
![]() The database class could use a better error handling, but it's just an example, don't shoot me. Good luck, ![]() Tuesday And that was when I ruled the world |
|
(#2 (permalink))
|
|
DivineBanhammer
|
12-27-2008, 06:21 PM
A good tutorial, as always
![]() » Help me continue WOGH development, donate« » Do not PM me for requests! « |
|
(#3 (permalink))
|
|
n00bie
![]() Posts: 1
Join Date: Oct 2009
Last Online: 11-05-2009 01:57 PM Reputation:
![]() User is Offline
|
10-31-2009, 03:30 PM
Better use PDO in php5, it's easier and works with a lot of db.
PHP: PDO - Manual Example Code:
$pdo = new PDO('mysql:host=localhost;dbname=myname', 'user', 'password');
$pdo -> query('SELECT * FROM users');
|
|
(#4 (permalink))
|
|
n00bie
![]() Posts: 19
Join Date: Jul 2008
Last Online: 12-27-2009 01:04 PM Reputation:
![]() User is Offline
|
11-05-2009, 08:58 AM
I added code highlighting (so using [ php ] and [ html ] instead of [ code ]) to all my tutorials: ![]() Basics of PHP Basic Javascript animations PHP5 - Basics of Classes And that was when I ruled the world |
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
| New To Site? | Need Help? |