I'm trying to connect to my MySQL database using PHP code and I'm getting this error:
This is the code I'm using:
Code:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'roblav96_baked96'@'74.63.233.5' (using password: YES) in /home/roblav96/public_html/sb/shoutbox.php on line 46
Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'roblav96'@'74.63.233.5' (using password: NO) in /home/roblav96/public_html/sb/shoutbox.php on line 47
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/roblav96/public_html/sb/shoutbox.php on line 47
Access denied for user 'roblav96'@'74.63.233.5' (using password: NO)
This is the code I'm using:
PHP:
<style type="text/css">
<!--
#contentbox {
background: #E5E5E5;
padding: 5px;
width: 200px;
height: 200px;
overflow: auto; }
ul#shoutboxmessage {
margin: 0;
padding: 0;
list-style-type: none;
color: #000000;
font: normal 10px verdana,tahoma,arial; }
-->
</style>
<?php
#require_once("config.php");
$dbhost = "mysql-cossacks.x10hosting.com";
$dbname = "roblav96_shoutbox";
$dbuser = "roblav96_baked96";
$dbpass = "mypassword";
$name = $_POST['name'];
$message = $_POST['message'];
$ip = $_POST['ip'];
$mlen = strlen($message);
$maxlength = 150;
$date = date("M jS Y");
if ($_POST['submit']) {
if ($name == "") {
echo "<strong>Error: Please enter your nickname.</strong>";
}
else if ($message == "") {
echo "<strong>Error: No message to be sent.</strong>";
}
else if ($mlen > $maxlength) {
echo "<strong>Error: Message too long.</strong>";
}
else {
$db = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($dbname) or die(mysql_error());
mysql_query("INSERT INTO shoutbox(name,message,date,ip) VALUES('$name','$message','$date','$ip')");
}
}
$db = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($dbname) or die(mysql_error());
$query = "SELECT * FROM shoutbox ORDER BY id DESC LIMIT 20";
$result = mysql_query($query);
echo "<div id=\"contentbox\">\n";
echo "<ul id=\"shoutboxmessage\">\n";
while($r = mysql_fetch_array($result)) {
$name = $r['name'];
$name = strip_tags($name);
$message = $r['message'];
$message = strip_tags($message);
echo "<li><strong>>$name</strong>: $message</li>\n";
}
echo "</ul>\n";
echo "</div>\n";
mysql_close($db);
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<strong>Nickname:</strong><br/>
<input type="text" name="name" maxlength="20"><<br/>
<strong>Message:</strong><br/>
<textarea name="message"></textarea><br/>
<input type="submit" name="submit" value="Shout It!">
<input type="hidden" name="ip" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>">
</form>
</div>
?>