Mysql

Status
Not open for further replies.

tinytinker

New Member
Messages
10
Reaction score
0
Points
0
ok im sorry for such a repetative subject on here but

Basically this is my db_connect.php
Code:
<?php

$database[dbserver]="localhost";
$database[dbuser]="********_tiny ";
$database[dbname]="********_tiny";
$database[dbpass]="***********";
$table ="table1";


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

However when i enter this in i get the following error
Code:
[B]Warning[/B]:  mysql_connect() [[URL="http://www.idai.exofire.net/function.mysql-connect"]function.mysql-connect[/URL]]: Access denied for user '********_tiny'@'localhost' (using password: YES) in [B]/home/********/public_html/db_connect.php[/B] on line [B]9[/B]

The stars are just my ID & Password.

my user names and db names are all cppanelname_loginname and cppanel_dbname

I cant see where i have gone wrong, i havent had a problem like this before





I get the same errors on this file also
Code:
<?php

/* 
*/
//Database Information
// Edit these Parts for your site
$dbhost = "localhost";
$dbname = "";
$dbuser = "";
$dbpass = ""; 

//Connect to database

mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());

$s_client_name = $_POST['s_client_name'];
$s_client_password = $_POST['s_client_password'];
$email = $_POST['email'];

$checkuser = mysql_query("SELECT s_client_name FROM ts2_clients WHERE s_client_name='$s_client_name'");

$s_client_name_exist = mysql_num_rows($checkuser);

if($s_client_name_exist > 0){
    echo "I'm sorry but the username you specified has already been taken.  Please pick another one.";
    unset($s_client_name);
    include 'index.php';
    exit();
}

$query = "INSERT INTO ts2_clients (s_client_name, s_client_password, i_client_server_id, b_client_privilege_serveradmin)
VALUES('$s_client_name', '$s_client_password', '0', '0')";
mysql_query($query) or die(mysql_error());
mysql_close();

echo "You have successfully Registered to Evolution";

/* Edit these details to fit your site and details */
$yoursite = ' www.idai.exofire.net ';
$webmaster = ' Evolution ' ;
$youremail = ' admin@idai.exofire.net ';

$subject = "You have successfully registered at $yoursite...";
$message = "Dear $s_client_name, you are now registered at our web site.  
    To login, simply go to our web page and enter in the following details in the login form:
    Username: $s_client_name
    Password: $s_client_password
    
    Please print this information out and store it for future reference.
    
    Thanks,
    $webmaster";
    
mail($email, $subject, $message, "From: $yoursite <$youremail>\nX-Mailer:PHP/" . phpversion());
    
echo "Your information has been mailed to your email address.";
?>


the above was part of an addon i did for teamspeak. It used to work fine when i hosted my website from home but now as i have a dynamic ip and a slower connection i decided to remotely host everything, Any help would be greatly appreciated.

Thanks
 

tinytinker

New Member
Messages
10
Reaction score
0
Points
0

ahah. Thanks i feel silly now

/Tiny
Edit:
i have intermediate now, but still recieving same errors

i have rewritten the code out a few times and cant see any errors on my half.

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)



Thanks

/Tinytinker
 
Last edited:

Corey

I Break Things
Staff member
Messages
34,551
Reaction score
204
Points
63
It is localhost, have you created your database through cPanel, created the user, and then set the permissions for the user to the database?
 

MasterMax1313

New Member
Messages
84
Reaction score
0
Points
0
i'm having a similar issue, where I cannot seem to connect to my mysql database. I've set one up in cPanel, with a user and with sufficient permissions. Originally I was trying to connect to the database with the name supplied through cPanel. This resulted in the page not finishing loading (echo points were set before and after the connect statement to gauge where I was stopping, and the one after the connect statement wasn't being hit). I also tried with localhost, where I received a message stating that the supplied username and password did not permit me to connect to localhost. I've also tried both the username that is generated through cPanel (username_dbUserName) and just the one I created (dbUserName), with identical results.

psuedo code
PHP:
$db = mysql_connect("localhost","userName_dbUser","passwd");
mysql_select_db("userName_dbName",$db);

I've had my account upgraded, but to no avail. Am I just forgetting something?
 

Corey

I Break Things
Staff member
Messages
34,551
Reaction score
204
Points
63
Database example:
My cPanel user name is staff. I go into cPanel and create a user named corey with a pass of temp123 and a database named stuff. I then give the user corey all permissions to stuff.

My connect statement will look like this:
PHP:
mysql_connect('localhost', 'staff_corey', 'temp123');
mysql_select_db('staff_stuff');

-Corey
 
Last edited:

MasterMax1313

New Member
Messages
84
Reaction score
0
Points
0
Well, I solved my issue. Apparently spaces are not valid characters, and therefore made the account useless. If I'm wrong, please correct me, but that seems to me to have been the problem. If this is the case, I'd like to suggest that in the process of submitting a password for the mysql database user, that a check be made that there are no white spaces in the password.
 

DefecTalisman

Community Advocate
Community Support
Messages
4,148
Reaction score
5
Points
38
Just a silly comment. Where in programing/scripting/coding can one use a white space other than for layout? This applies to passwords and usernames I am sure.
 

panop

New Member
Messages
64
Reaction score
0
Points
0
Not for here, all usernames and passwords have to use an underscore for spaces. If you look up in your script, all of your usernames use ' or " to enclose them. PHP reads this as telling it to read the entire thing. However, if there is a break in that variable, php gets confused and gives an error message.
 
Status
Not open for further replies.
Top