dynamicgfx Posted July 25, 2012 Share Posted July 25, 2012 Hi there ive got this php code for a shoutbox im working on but i keep getting the error: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'a7865530_shout'@'localhost' (using password: YES) in /home/a7865530/public_html/index.php on line 66 The while loop works its just when im inserting something it give an error <style> table { border:thin solid #000; width:600px; font-family:arial; } th { color:#fff; background:#000; } </style> <? $username="a7865530_shout"; $password="passwordishere"; $database="a7865530_shout"; $host="mysql16.000webhost.com"; if(!isset($_GET['insert'])){ ?> <meta http-equiv="REFRESH" content="20;url=/"> <table style="max-height:600px;overflow:scroll;" border="0"> <tr> <th>Name:</th> <th>Message:</th> </tr> <?php $con = mysql_connect($host, $username, $password); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db($database , $con); $result = mysql_query("SELECT * FROM shout"); while($row = mysql_fetch_array($result)) { echo "<tr><td>"; echo stripslashes($row['name']) . "</td><td/> " . stripslashes($row['message']); echo "</td></tr>"; } mysql_close($con); ?> </table> <table border="0" cellspacing="0" cellpadding="0"> <form name="addform" method="post" action="?insert"> <tr> <td align="center"> Name: <input type="text" id="name" name="name"> Message: <input type="text" id="message" name="message"> <input type="submit" name="shout" title="shout" value="shout"> </td> </tr> </table> </form> <?php } else { $table="shout"; $name = $_POST['name']; $message = $_POST['message']; $name = stripslashes($name); $message = stripslashes($message); $ip = $_SERVER['REMOTE_ADDR']; mysql_connect($$host,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="INSERT INTO $table (ip,name, message) values ('$ip','$name','$message')"; $result=mysql_query($query); echo "Succsesfully Shouted. <a href=\"/\">Return</a>"; header("location: .../index.php"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/266227-shoutbox-code-cant-understand-why-it-gives-an-error/ Share on other sites More sharing options...
xyph Posted July 25, 2012 Share Posted July 25, 2012 Something looks wrong on line 66 mysql_connect($$host,$username,$password); Quote Link to comment https://forums.phpfreaks.com/topic/266227-shoutbox-code-cant-understand-why-it-gives-an-error/#findComment-1364266 Share on other sites More sharing options...
dynamicgfx Posted July 25, 2012 Author Share Posted July 25, 2012 Something looks wrong on line 66 mysql_connect($$host,$username,$password); oh lol thanks Quote Link to comment https://forums.phpfreaks.com/topic/266227-shoutbox-code-cant-understand-why-it-gives-an-error/#findComment-1364267 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.