mysql

Status
Not open for further replies.

tinytinker

New Member
Messages
10
Reaction score
0
Points
0
Can anyone lend a hand at all?

I have the intermediate php (Version 2?)


The mysql server is localhost i assume...

Error i get is

Code:
[B]Warning[/B]: mysql_connect() [[URL="http://forums.x10hosting.com/function.mysql-connect"]function.mysql-connect[/URL]]: Access denied for  user 'tinytink_tiny'@'localhost' (using password: YES) in  [B]/home/tinytink/public_html/db_connect.php[/B] on line [B]9[/B]

Line 9 of db_connect is the last line of code (my complete db_connect is below)
Code:
$connect = mysql_connect($database['dbserver'], $database['dbuser'], $database['dbpass']);

DB Connect
I enter my db user and db name in the normal way of "CPPANELNAME_USER" & "CPPANELNAME_DBNAME"
Code:
 <?php
 
$database[dbserver]="localhost";
$database[dbuser]="";
$database[dbname]="";
$database[dbpass]="";
 
 
$connect = mysql_connect($database['dbserver'], $database['dbuser'], $database['dbpass']);
?>



The code i use on registration page to embed this is
Code:
<? 
Include("header.php");
require_once($_SERVER['DOCUMENT_ROOT'].'/db_connect.php');
 
?>

i cannot see anywhere i have gone wrong :/ could someone give me any pointers

(my php isnt that great so if i am wrong with anything i appologise)
 

Brandon

Former Senior Account Rep
Community Support
Messages
19,181
Reaction score
28
Points
48
In cPanel, you need to grant permissions to your user & database, it can be done on the MySQL page.

If you don't know what they do, I would just do all so you don't run into problems.
 

tinytinker

New Member
Messages
10
Reaction score
0
Points
0
In cPanel, you need to grant permissions to your user & database, it can be done on the MySQL page.

If you don't know what they do, I would just do all so you don't run into problems.
already done this and still getting same error

i did double check i even made a new db and user name etc and added that user to the new db with all priv, and no luck
 
Last edited:

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
Well it seems like a mysql password error, have you tried phpMyAdmin to see if you can connect to the database at all?
 

tinytinker

New Member
Messages
10
Reaction score
0
Points
0
Well it seems like a mysql password error, have you tried phpMyAdmin to see if you can connect to the database at all?

aye indeed. and yes i have and yes i can :/

this is why im getting confused

in my db_connect i wouldnt need to put a tabe in at all?

Code:
 <?php
 
$database[dbserver]="localhost";
$database[dbuser]="";
$database[dbname]="";
$database[dbpass]="";
 
 
$connect = mysql_connect($database['dbserver'], $database['dbuser'], $database['dbpass'], $table);
?>

that kinda thing?

i should really learn more php :'(
 
Last edited:

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
The syntax for a sample connection should be
PHP:
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
mysql_select_db('database_name', $link) or die('Could not select database.');
 

tinytinker

New Member
Messages
10
Reaction score
0
Points
0
i use this script as i made it as a na addon for teamspeak, (webpage registration & login) it worked on my own setup at home, obv things are diff here, just wondering if its something to do with php restrictions at all although i cant see that being the problem cause im not really trying to do anything all that complex


Basically in registration page i use this

Code:
 require_once('db_connect.php');


which i think is correct? it used to work before i changed to here.

and in db connect is

Code:
 <?php

$database[dbserver]="localhost";
$database[dbuser]="";
$database[dbname]="";
$database[dbpass]="";

$connect = mysql_connect($database['dbserver'], $database['dbuser'], $database['dbpass']);
?>


now as i get the acess denied message im assuming nothing wrong with my code and that it really is a password issue.

so im gonna go away and try another username and password and post back the results.

Thanks for help slothie



edit:
Have found out the problem and now fixed it. Thanks for all your help slothie, turns out it was a password error somewhere, i noticed i still had the connect script in the register page and also doing a require for the seperate page so i was trying to connect with one scrpt with correct pass and also trying to connect with incorrect password. HA. i feel very stupid, thanks for help though.
 
Last edited:
Status
Not open for further replies.
Top