gracecodesign Posted November 16, 2005 Share Posted November 16, 2005 This is probably so simple but I am really new to MySQL and PHP. Are there any backend preferences or settings to think about? Help! error message :: Access denied for user: 'gracecod_simple@localhost' to database 'gracecod_simpleauth' php script :: <?php error_reporting(E_ALL); include_once("functions.php"); session_register("login"); session_register("password"); session_register("loggedIn"); $messages=array(); $dbhost="localhost:8080"; $dbuser="gracecod_simple"; $dbpass="*"; $dbname="gracecod_simpleauth"; $conn = connectToDB($dbhost,$dbuser,$dbpass,$dbname); function connectToDB($dbhost,$dbuser,$dbpass,$dbname) { $conn = mysql_connect($dbhost,$dbuser,$dbpass) or die(mysql_error()); mysql_select_db($dbname,$conn) or die(mysql_error()); return $conn; } ?> thanks so much Link to comment https://forums.phpfreaks.com/topic/2878-database-connectivity/ Share on other sites More sharing options...
MxpUnk Posted December 4, 2005 Share Posted December 4, 2005 [!--quoteo(post=319252:date=Nov 16 2005, 03:43 PM:name=GraceandCo)--][div class=\'quotetop\']QUOTE(GraceandCo @ Nov 16 2005, 03:43 PM) 319252[/snapback][/div][div class=\'quotemain\'][!--quotec--] Access denied for user: 'gracecod_simple@localhost' to database 'gracecod_simpleauth' The obove error is just a connecting to the database error. It's simple to fix. 1. You can edit the below code to match you're database. $conn = connectToDB($dbhost,$dbuser,$dbpass,$dbname); function connectToDB($dbhost,$dbuser,$dbpass,$dbname) { $conn = mysql_connect($dbhost,$dbuser,$dbpass) or die(mysql_error()); mysql_select_db($dbname,$conn) or die(mysql_error()); return $conn; Also, if you already have a connect.php file for your site, that is correct, you can do <?php include('connect.php'); ?> That does the same thing as you had, so. If you don't have a connect.php file, I would make one.. <?php ob_start(); @mysql_connect("localhost","db_name","password") or die(' <link href=style.css rel=stylesheet> <Br> Down <br> Could not connect; ' . mysql_error()); mysql_select_db("db_name"); ?> The above is how I make my connect.php, there are some other ways.. But like I said if you dont have connect, you might want it Also: $dbhost="localhost:8080"; $dbuser="gracecod_simple"; $dbpass="*"; $dbname="gracecod_simpleauth"; Just checking, but the $dbname you're connecting too could be wrong too. Well anyway, I tried to explain this in simplist form, and as I said it's VERY simple to overcome. Just change the db names around, and connect, and you've got it! [!--quoteo(post=319252:date=Nov 16 2005, 03:43 PM:name=GraceandCo)--][div class=\'quotetop\']QUOTE(GraceandCo @ Nov 16 2005, 03:43 PM) 319252[/snapback][/div][div class=\'quotemain\'][!--quotec--] Access denied for user: 'gracecod_simple@localhost' to database 'gracecod_simpleauth' The obove error is just a connecting to the database error. It's simple to fix. 1. You can edit the below code to match you're database. $conn = connectToDB($dbhost,$dbuser,$dbpass,$dbname); function connectToDB($dbhost,$dbuser,$dbpass,$dbname) { $conn = mysql_connect($dbhost,$dbuser,$dbpass) or die(mysql_error()); mysql_select_db($dbname,$conn) or die(mysql_error()); return $conn; Also, if you already have a connect.php file for your site, that is correct, you can do <?php include('connect.php'); ?> That does the same thing as you had, so. If you don't have a connect.php file, I would make one.. <?php ob_start(); @mysql_connect("localhost","db_name","password") or die(' <link href=style.css rel=stylesheet> <Br> Down <br> Could not connect; ' . mysql_error()); mysql_select_db("db_name"); ?> The above is how I make my connect.php, there are some other ways.. But like I said if you dont have connect, you might want it Also: $dbhost="localhost:8080"; $dbuser="gracecod_simple"; $dbpass="*"; $dbname="gracecod_simpleauth"; Just checking, but the $dbname you're connecting too could be wrong too. Well anyway, I tried to explain this in simplist form, and as I said it's VERY simple to vercome. Just change the db names around, and connect, and you've got it! Link to comment https://forums.phpfreaks.com/topic/2878-database-connectivity/#findComment-10013 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.