Jump to content

Access Denied When Connecting to Database


tim101011

Recommended Posts

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 



?>





 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.