0 Users appreciate this thread.
PHP, MYSQL :: Lesson 1
klubadmin (2012-11-07 02:46:12)2012-11-09 22:32:20
Log in to submit a comment
Back to forum: Web Programming (HTML, JS, CSS, PHP, MySQL)
New registered users today: 7
Newest registered user: ElegantVulpes

PHP and MYSQL is everywhere on this site. This lesson will tell you how to make a basic connection to a database (MYSQL server).
Start with:
$con = mysql_connect("localhost","DBUSER","DBPASS"
Replace DBUSER with the database user that you assigned. Replace DBPASS with the user password.
Then type:
if (!$con)
{
die ("Could not connect: " . mysql_error());
}
This tells the browser if connection fails, say what is in the "".
next type:
$db = mysql_select_db("DBNAME"
Replace DBNAME with the database name.
Last type:
if (!$d
{
die ("Could not select database: " . mysql_error());
}
This tells the browser if selection of database fails, say what is between the "".
The full code:
$con = mysql_connect("localhost","DBUSER","DBPASS"
if (!$con)
{
die ("Could not connect: " . mysql_error());
}
$db = mysql_select_db("DBNAME"
if (!$d
{
die (Could not select database: " . mysql_error());
}
Cya!