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"); } ?> 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 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. 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"); 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! Link to comment https://forums.phpfreaks.com/topic/240106-error-while-hosting/#findComment-1233345 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.