Left Quote    If at first you don't succeed, redefine success.
- Anon.    
Right Quote
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply

        Viewing Topic: Access denied for user 'vhostswww'@ 'localhost' (using pa
  This user is offline  miswu13
  Subject: "Access denied for user 'vhostswww..." Posted: @ 4:50 am on Aug 09 2008   
Member #: 737
Rank: user - (1)
Since: 08/09/08
Posts: 1

Sorry if this subject was talked, but i haven't found the search button .

I followed the tutorial, of Complete Members System, but the codes haven't worked for me... In order to resolve some of my errors, i found some tricks and made it work : (put <b>@</ b> in front of <b>mysql_ query</b> , <b>mysql_ fetch_object< ;/b> and <b>mysql_ query</b> ; and instead of <b>requir e_once($_SERVER ['DOCUMENT_ROOT '].'/db_connect .php');</b&g t;, i entered <b>requir e_once('db_conn ect.php');</ b> ).

But still it doesn't work; when i go to register.php , i get the following error:

<quote>Ac cess denied for user 'vhostswww'@'lo calhost' (using password: NO)</quote&g t; .

My question is where is that "whostwww& quot; from, and how can i remediate that?

I have the following code for register.php

require_once('d b_connect.php') ;


if($_SESSION[' logged_in'] == 1)
header('Locatio n: http:/www.stude nt-radio.vndv.c om/index.htm/' . $_SERVER['HTTP_ HOST'] . '');
} else {

if(isset($HTTP _POST_VARS['sub mit']))


if(!$_POST['use rname']) die('Alert: username field was blank.');

//array of invalid characters
$junk = array('.' , ',' , '/' , '`' , ';' , '[' , ']' , '\\',
'*', '&', '^', '%', '$', '#', '@', '!', '~', '+', '(', ')',
'|', '{', '}', '<', '>', '?', ':', '"', '=');

//starting lenght of username
$len = strlen($_POST[' username']);

//replace invalid characters
$_POST['usernam e'] = str_replace($ju nk, '', $_POST['usernam e']);
$test = $_POST['usernam e'];

//if lenghts are different ($len smaller), invalid characters found, so prompt error.
if(strlen($test ) != $len) {
die('Username Error: Username contained invalid characters. You can only use A-Z, 0-9 and the

underscore (_).');

//Check if username already exists...

$q2 = @mysql_query(&q uot;SELECT * FROM `members` WHERE `username` = '".$_POST[ 'username'].&qu ot;'";
$q3 = @mysql_fetch_ob ject($q2);

if($q3->user name == $_POST['usernam e']) {
die('<BR> ;<BR>Sorr y, but the username "'.$q3-> ;username.'&quo t; is taken, please choose another.');


if(!$_POST['pas sword']) {
die('Error: Password field was blank');
if(!$_POST['ver ify_password']) {
die('Error: Verify Password field was blank.');
if($_POST['pass word'] != $_POST['verify_ password']) {
die('Error: The passwords do not match.');
if(strlen($_POS T['password']) < 6 ) {
die('Error: Your password is too short. Must be 6 or more characters in length.');


$insert ="INSERT INTO `members` (username, user_password, user_email) VALUES ('".$_POST ['username'].&q uot;',

'".md5($_P OST['password'] )."', '".$_POST[ 'email']." ')";

$insert2 = @mysql_query($i nsert);
if(!$insert2) die(mysql_error ());

echo('Registrat ion Successful, Welcome new member! You can now login to your new account.');

} else {
<form name="sign up" action="&l t;? $_SERVER['PHP_S ELF']; ?>" method="PO ST">
<td>Usern ame: <BR> (only A-Z, 0-9 and _ Allowed)<BR& gt;</td>
<td><i nput type="text " id ="username " name="user name" value="&qu ot; maxlength=" ;30"> <BR></ td>
<td>Passw ord:</td>
<td><i nput type="pass word" id="passwo rd" name="pass word" value="&qu ot; maxlength=" ;30">&l t;BR> (minimum 6

characters)< /td>
<td>Verif y Pass:</td> ;
<td><i nput type="pass word" id="verify _password" name="veri fy_password&quo t; value="&qu ot; maxlength=" ;30">&l t;BR>

<td>Email :</td>
<td><i nput type="text " id="email& quot; name="emai l" value="&qu ot; size="30&q uot;><br& gt;</td>
<td>Click to Complete Signup:</td& gt;
<td><i nput type="subm it" id="submit " name="subm it" value="sub mit">&l t;/td>
} //end not logged in
} //end submit not pressed

I guess that the problem is when adding a new member, on line 64-69, but i can't get it work.

Please take a look at my problem, i am a complete beginner in php development, but i am willing to learn from my mistakes.

Thanks !

Edited at 05:15:33 am on 08/09/08

    Viewed: 8,418 Times | Reply to This | To top
  This user is offline  viospace
  Subject: "re: Access denied for user 'vhosts..." Posted: @ 9:38 pm on Aug 10 2008    

Member #: 717
Rank: user - (7)
Since: 07/13/08
Posts: 4
From: Fairless Hills, PA


you may want to try some syntax changes (a few less ' and " ) and getting the meta data.

$query ="INSERT INTO `members` (username) VALUES ('$_POST[usern ame]')";

$result = mysql_query($qu ery,$connectdb) ;

$insert ="INSERT INTO `members` (username, user_password, user_email) VALUES ('".$_PO ST['username' ]."',

'".md5($ _POST['passwor d'])."' , '".$_POS T['email'].& quot;')" ;

$insert2 = @mysql_query($i nsert);
if(!$insert2) die(mysql_error ());

dogstar "I want a sandwich!" ;

    Viewed: 8,395 Times | Reply to This | To top
  This user is offline  Ghezus
  Subject: "re: Access denied for user 'vhosts..." Posted: @ 6:07 pm on Aug 17 2008    

Member #: 125
Rank: user - (3)
Since: 12/24/05
Posts: 3
From: Netherlands

It seems like you didn't setup your MySQL user name and password and thus it returns a error that it can't log in to your MySQL server.

You probably forgot to set them in your 'db_connect .php'.

I also don't think this is the right tutorial for you if you don't know this simple error. Perhaps start with something simple about writing and reading the database (a visitor counter tutorial or such) to get you started.

Edited at 06:09:55 pm on 08/17/08 | 342868497 | ghezus |     Viewed: 8,316 Times | Reply to This | To top
Viewing Page: 1 of 1

1 |

You must be logged in to post on the forums. Login or Register

"" Copyright © 2002-2021; All rights lefted, all lefts righted.
Privacy Policy