I have recently begun experimenting with PHP and MySQL. I have put together a sample database and the following PHP in my web page. I have removed the actual user name and password as my host uses the main log in username/password for database management. When I run the page on line I get an "access denied" message but I know the password and username are correct and I have set the permissions to 777. Can anyone suggest what I am doing wrong or any alternative methods of connecting to the localhost.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" x-undefined>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>
<body>
<?php
$vusername = "*****"; //your username for you local system
$pwd ="*****"; //password to accecss mySQL
$host = "localhost"; //host is localhost - even for most web hosts
$dbname = "Pets"; //db name to be accessed
//connect to db
//$conn=mysql_connect($host, $username, $pwd) or die ("Unable to connect to database");
if (!($conn=mysql_connect($host, $vusername, $pwd))) {
printf("error connecting to DB by user = $username and pwd=$pwd");
exit;
}
$db=mysql_select_db($dbname,$conn) or die("Unable to connect to database1");
?>
</body>
</html>
😕