Username:
Password:
Remember me:
Register

Back to forum: Web Programming (HTML, JS, CSS, PHP, MySQL)


Search forums via Google


0 Users appreciate this thread.

MySQL - PHP Connect
Started by angelrulez7
(2012-08-26 03:10:56)
angelrulez7 (2012-08-26 03:10:56)
I've seen some off topic questions asking how to connect to a database...

connect.php should be:

<?
$connect=mysql_connect(DB_SERVER, DB_USER, DB_PASS);
mysql_select_db(DB_NAME);
?>

And to use it on any page?

<?include ('connect.php' ?>

KTHXBAI.

This post has been edited one or more times, the last time was:
2012-08-26 03:11:42

a
SPCOxion (2012-08-26 03:20:24)
Try checking out the MySQL and PHP tutorials at TNB.
angelrulez7 (2012-08-26 03:44:37)
:l....

No.
a
djl12328 (2012-08-26 04:08:50)
connect.php should be:

$db_host = "MyHost";
$db_username = "MyUsername";
$db_pass = "MyPass";
$db_name = "MyDatabase";

mysql_connect("$db_host","$db_username","$db_pass" or die(mysql_error());
mysql_select_db("$db_name" or die("no database by that name";

just replace the variable contents with your host, password, user, and database name.

To include it, just use:

include_once 'connect.php';
www.dark-isle.weebly.com
angelrulez7 (2012-08-29 07:01:49)
Or plain include.
a
 

Log in to submit a comment

This topic's ID: 29159

Back to forum: Web Programming (HTML, JS, CSS, PHP, MySQL)




Total registered users: 8321
New registered users today: 7
Newest registered user: ElegantVulpes

©  Copyright 2026 3DSPlaza. All Rights Reserved