PDA

View Full Version : Problem when connecting to a MySQL-DB using PHP


Nezzar
December 31st, 2001, 10:33
I used this code:


$dbserver = "localhost";
$dbname = "php-test";
$dbuser = "root";
$dbpass = "";

$dbcon = MYSQL_CONNECT($dbserver,$dbuser,$dbpass) or die ("Connection to database-server failed");
if ($dbcon)
{
print "Connection to Database succesful";
};


The Problem is that PHP always says that the connection succesful. I'm quite new to this whole PHP-thing and this is not a very difficult problem, I guess.

404
December 31st, 2001, 11:28
You must have the exact information on your MySQL account (database name, user name, password), otherwise it won't work.

Look at here:

$dbserver = "localhost"; <-- no need to change this, most server use localhost as default
$dbname = "php-test"; <-- your database name
$dbuser = "root"; <-- your user name
$dbpass = ""; <-- don't fill this blank, or MySQL think it's anonymous


;)

Nezzar
December 31st, 2001, 13:31
Just found out that I can logon to my local DB with any username:emb: