Reputation: 5413
I have my XAMPP running up apache and mysql are running and try to a simple mysql_connect
mysql_connect('localhost', 'root', 'test123');
but the mysql_error() comes back with
Failed to connect to MySQL host. Access denied for user 'root'@'localhost' (using password: YES)
So, I open up config.inc.php inside myphpadmin and verified the credentials are correct.
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'config';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'test123';
$cfg['Servers'][$i]['connect_type'] = 'socket';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = true;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysql';
The only thing I am not sure is the $cfg['Servers'][$i] thing. What's this $i? Are there multiple instances of Servers?
Upvotes: 0
Views: 1053
Reputation: 515
try this one:
$hostname_koneksi = "localhost";
$database_koneksi = "your_database";
$username_koneksi = "your_username";
$password_koneksi = "your_password";
$koneksi = mysql_pconnect($hostname_koneksi, $username_koneksi, $password_koneksi) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_koneksi) or die("Can't open the database!");
Edit:
you create this script on a file, and use include
function to the file that you want to use this connection..
this is my own setting on config.inc.php
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysql if your server does not have mysqli */
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
Upvotes: 0