mariam Posted June 22, 2011 Share Posted June 22, 2011 i wrote a for loging in a specific page.... logiing in just requires the username attribute.. no password is required. it works fine on local host using xamp but when i host the website it gives the following error: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'a3907930_root'@'10.1.1.42' (using password: NO) in /home/a3907930/public_html/doc_checklogin.php on line 15 following is the code: <?php $host = "mysql14.000webhost.com"; $db_name = "a3907930_mehreen"; $username = "a3907930_root"; $password = "aaaAAA111"; $tbl_name="members"; //$host="localhost"; // Host name //$username="root"; // Mysql username //$password=""; // Mysql password //$db_name="mehreen"; // Database name //$tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect($host, $username)or die("cannot connect"); mysql_select_db($db_name)or die("cannot select DB"); // username sent from form $myusername=$_POST['myusername']; $sql="SELECT * FROM $tbl_name WHERE username='$myusername'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, and redirect to profile file session_register("myusername"); } //addition: if ($myusername=='mariam') { header ("location:mariam_profile.php"); } elseif ($myusername=='mehreen') { header ("location:mehreen_profile.php"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/240106-error-while-hosting/ Share on other sites More sharing options...
freelance84 Posted June 22, 2011 Share Posted June 22, 2011 Hi, That usually means that either the username or password is incorrect to log in to your mysql database online Quote Link to comment https://forums.phpfreaks.com/topic/240106-error-while-hosting/#findComment-1233330 Share on other sites More sharing options...
PFMaBiSmAd Posted June 22, 2011 Share Posted June 22, 2011 You actually need to use the password in the mysql_connect() statement. Quote Link to comment https://forums.phpfreaks.com/topic/240106-error-while-hosting/#findComment-1233331 Share on other sites More sharing options...
dragon_sa Posted June 22, 2011 Share Posted June 22, 2011 You actually need to use the password in the mysql_connect() statement. like this mysql_connect($host, $username, $password)or die("cannot connect"); Quote Link to comment https://forums.phpfreaks.com/topic/240106-error-while-hosting/#findComment-1233334 Share on other sites More sharing options...
mariam Posted June 22, 2011 Author Share Posted June 22, 2011 yes it worked like that. thanx! Quote Link to comment https://forums.phpfreaks.com/topic/240106-error-while-hosting/#findComment-1233345 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.