codequirks
Programmer
Hi there
I am a little new to php having been working in the dark world of databases for many years. I am in the process of creating my first website but whilst the php and the database stuff work great I cannot get the two to talk. The error is: DB connection failed: Access denied for user 'phpaccess'@'localhost' (using password: YES). I think this is likely just a small config or privilege tweak - can any of you experts help? The user is 'phpaccess'@'%' and only has select privilege on db_mydatabase - nothing else
As always thanks for your time in advance and code below:
I am a little new to php having been working in the dark world of databases for many years. I am in the process of creating my first website but whilst the php and the database stuff work great I cannot get the two to talk. The error is: DB connection failed: Access denied for user 'phpaccess'@'localhost' (using password: YES). I think this is likely just a small config or privilege tweak - can any of you experts help? The user is 'phpaccess'@'%' and only has select privilege on db_mydatabase - nothing else
As always thanks for your time in advance and code below:
Code:
----Test PHP File
<HEAD><TITLE>HTML, PHP, MySQL Test Page</TITLE></HEAD>
<BODY>
<?PHP
//Run phpinfo to make sure MySQL is loaded and working
phpinfo();
//Set up database connection parameters
$myServer = "127.0.0.1";
$myUser = "phpaccess";
$myPass = "phppassw0rd";
$myDB = "db_mydatabase";
//Open mySQL connection with all errors reported
ini_set('display_errors', 1);
error_reporting(E_ALL);
$connection = mysql_connect($myServer, $myUser, $myPass);
if (!$connection)
{
die("DB connection failed: " . mysql_error());
}
//Activate database and then query the table
$activedb = mysql_select_db($myDB, $connection) or die ("Couldn't open database");
$query = mssql_init("SELECT * FROM `tb_users`", $connection);
$result = mssql_execute($query);
echo "success";
mysql_close($connection);
?>