Jump to content

Archived

This topic is now archived and is closed to further replies.

gracecodesign

Database connectivity

Recommended Posts

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

 

Share this post


Link to post
Share on other sites

[!--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. :P

 

 

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. :P

 

 

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! :)

 

 

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.