Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

MySql Registration

Newbie Spellweaver
Joined
Apr 20, 2008
Messages
14
Reaction score
0
Well i have made sure the username says root, the password says my password, and the hostname is localhost, but i'm getting this error and i don't have a clue why:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in /www/gethosted.info/n/e/o/neuro/htdocs/checkreg.php on line 5

This is the regcheck:
<?php
$username = "root";
$password = "Mypass(normal 1 is correct)";
$hostname = "localhost";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL Database.");
mysql_select_db("coproj");
$regwho=stripslashes($_POST['regwho']);
$regcred=stripslashes($_POST['regcred']);
mysql_real_escape_string($regwho);
mysql_real_escape_string($regcred);
$regc = ($regcred);
$login = mysql_query("SELECT * FROM accounts WHERE AccountID='$regwho'
OR AccountID='$regwho' AND Password='$regcred'")
or die ('Error: ' . mysql_error());
if ($row = mysql_fetch_array($login)){
echo 'This username is already taken. Please try again with a different username.
<br><br><a href="register.php">Try again</a>';
}
else {
$sql = "INSERT INTO accounts VALUES ('$_POST[regwho]', '', '2', '0', '')";
mysql_query($sql)
or die('Error: ' . mysql_error());
echo 'Registration successful. You may now log into Conquer private server.';
echo '<BR><BR>';
echo 'Have a nice day ' . $_POST['regwho'] . '.';
}
?>

can anyone help me out i dont have a clue whats wrong. I have a router and i have opened the port 3306.

Thanks
 
C# Developer
Joined
Jan 27, 2008
Messages
541
Reaction score
12
well, for the database selection, use something like

$dbsl = mysql_select_db($dbname);

and in order to use the or die, use an if statement. Such as

if($dbh){
echo 'Connected Successfully';
} else {
die('Unable to connect to MySQL Database');
}


Also, on your
$dbh = mysql_connect($hostname, $username, $password)
End it with a ;
 
Back
Top