tim101011 Posted October 21, 2007 Share Posted October 21, 2007 I have a page on my website that checks a persons details who wants to sign up for an account. One of the checks involves checking the username hasn't already been taken. This involves checking the username the user entered on the signup page against usernames in the database. Obviously I need to connect to the database to do this. "checksignup.php" which performs the checks calls my db connection script "connect.php" Checksignup.php is currently stalling: it is displaying this error message Warning: mysql_query() [function.mysql-query]: Access denied for user 'www-data'@'localhost' (using password: NO) in /var/www/vhosts/propertyeagle.co.uk/httpdocs/checksignup.php on line 8 here is the beggining of checksignup.php, line 8 is marked with a * <?php //Has the username already been taken? require_once ('./connect.php'); $username = $_POST['userid']; $sql="SELECT * FROM user WHERE username='$username'"; * $result=mysql_query($sql); $count=mysql_num_rows($result); if ($count>0){$errorpresent=1; $_SESSION['$usernametaken']=1;} And connect.php (I have checked the username password and database name, they are defintiely correct, but I have changed them here for the sake of security): <?php $host="localhost"; // Host name $username="bob"; // Mysql username $password="hello999"; // Mysql password $db_name="timsdb"; // Database name ?> Quote Link to comment https://forums.phpfreaks.com/topic/74200-access-denied-when-connecting-to-database/ Share on other sites More sharing options...
938660 Posted October 21, 2007 Share Posted October 21, 2007 use that: $sql = "SELECT * FROM users WHERE username = '$username'"; $result = mysql_query($sql) or die(mysql_error()); $num=mysql_num_rows($result); if ($num){ $errors .="That username is already in use<Br>";} Quote Link to comment https://forums.phpfreaks.com/topic/74200-access-denied-when-connecting-to-database/#findComment-374772 Share on other sites More sharing options...
only one Posted October 21, 2007 Share Posted October 21, 2007 Um where's your mysql_connect and mysql_select_db functions? Quote Link to comment https://forums.phpfreaks.com/topic/74200-access-denied-when-connecting-to-database/#findComment-374773 Share on other sites More sharing options...
tim101011 Posted October 21, 2007 Author Share Posted October 21, 2007 oops, sorry, yes that was it, i had commented those two lines out for a previous debugging: Um where's your mysql_connect and mysql_select_db functions? Quote Link to comment https://forums.phpfreaks.com/topic/74200-access-denied-when-connecting-to-database/#findComment-374797 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.