Username:
Password:
Remember me:
Register

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


Search forums via Google


0 Users appreciate this thread.

PHP, MYSQL :: Lesson 1
Started by ryanb000977
(2012-11-07 01:07:25)
ryanb000977 (2012-11-07 01:07:25)
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!
klubadmin (2012-11-07 02:46:12)
Put the code in [code][/code] to remove the emoticons.

This post has been edited one or more times, the last time was:
2012-11-09 22:32:20

socialcu.be
3dsklub.cf

Like what I said? +respect
>Official Trinate Spriter<
klubadmin (2012-11-09 22:32:09)
Whoops, perhaps not.
socialcu.be
3dsklub.cf

Like what I said? +respect
>Official Trinate Spriter<
 

Log in to submit a comment

This topic's ID: 35688

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