|
|
|
|
![]() ![]() |
Apr 8 2006, 01:06 AM
Post
#1
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 357 Joined: 8-April 06 Member No.: 21,487 |
hi all
this is my first Tut i hope you enjoy it At first Open Notepad.exe then write this code :: CODE <?php mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("news") or die(mysql_error()); ?> And Save it With Connect.php name With that code you can connect to MySql to manage (add/Delete/Update) Row or ..... and now we talk about that code : <?php <------------- at first line php is begin ------------- > mysql_connect("localhost","username","password") or die(mysql_error()); localhost :: where is your sql ! if your sql in your CPanel You must write localhost Username :: like username password :: like sql password mysql_select_db("databasename") or die(mysql_error()); Databasename = Your database name * if Your domain is asd.com and then you make news database your database name = asd_news ?> <------------- end of php ------------- > with this script you can just connect to database for read / write / delete / update you must user query have good time |
|
|
|
Apr 22 2006, 10:40 PM
Post
#2
|
|
|
Newbie ![]() Group: Members Posts: 2 Joined: 22-April 06 Member No.: 22,297 |
I use this as a script for noobs, it works easy
CODE mysql.php $server = "localhost"; //Deafault is localhost, only change if you are using this script remotely $user = "root"; //mysql user $password = ""; /mysql pass $database="db"; //databse ############################# ####DO NOT EDIT BELOW THIS LINE#### ############################ mysql_connect($server, $user, $pass) or die("Could not connect to mysql: ".mysql_error()); mysql_select_db($database) or die("Could not connect to mysql database: ".mysql_error()); then in any page you want to use, as long as it is in the same folder, do CODE <?php include("mysql.php"); ?> <html> <body>page here</body</html> |
|
|
|
Apr 25 2006, 12:55 PM
Post
#3
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 357 Joined: 8-April 06 Member No.: 21,487 |
Yes In big CMS Connecting To Database In One File and an other File include Database File
its mean don't write 20 line code for every page . In Big CMS this File name is config.php some times setup.php or db.php but config.php is popular |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 6th September 2008 - 02:00 AM |