Page 1 of 3

a weird error

Posted: Thu Aug 10, 2006 11:22 am
by Obadiah
ok....i finnally got that to work but now...after i worked out the bugs for my include pages i get

Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'admin'@'localhost' (using password: NO) in on line 5


line 5 of the file its pointing to says

Code: Select all

$cxn = mysqli_connect($host,$user,$password)
		or die ("Couldn't connect to server.");
the whole file being

Code: Select all

<?php
function Connect_to_db($filename)
{
	include($filename);
	$cxn = mysqli_connect($host,$user,$password)
		or die ("Couldn't connect to server.");
	$db = mysqli_select_db($cxn,$database)
		or die ("Coulden't select database.");
}
?>
and here is the kicker.....when i change the password in the and user name to access the database in the main file(the main file being simply)

Code: Select all

<?php
	$host = "localhost";
	$user = "****";
	$passwd = "****";
	$database = "********";
?>
it still says the same thing....am i going about this the wrong way?

Everah | Edited to remove potentially private data.

Posted: Thu Aug 10, 2006 11:30 am
by volka
mysql error -> http://www.mysql.com/search/index.php
search for access denied


edit: also try

Code: Select all

<?php
function Connect_to_db($filename)
{
	require $filename;
	
	if ( !isset($host,$user,$password,$database) ) {
		die('one or more required connection parameters not set');
	}
	
	echo "Debug: mysqli_connect($host,$user,$password)";
	$cxn = mysqli_connect($host,$user,$password)
		or die ("Couldn't connect to server.");
	$db = mysqli_select_db($cxn,$database)
		or die ("Coulden't select database.");
} 
?>

Posted: Thu Aug 10, 2006 11:42 am
by Obadiah
but im using xampp....that link tells me to connect to my database using CMD but when i try that i get a error that says bad syntax...so next i tried just going to the folder in xampp that mySQL is installed in and it had a .exe when i clicked it it didnt promt me for anything it was just a blank cmd screen without a path and just a prompt....what do i do

Posted: Thu Aug 10, 2006 11:48 am
by volka
forget it.
What about the code snippet?

Posted: Thu Aug 10, 2006 1:30 pm
by Obadiah
it says

one or more required connection parameters not set. can u explain to me the difference in your snippet....why it gave a different error and why mine gave a connection error? how can i avoid the connection issue in the future?

Posted: Thu Aug 10, 2006 4:01 pm
by volka
My version tests, wether there are those variables you want to use with mysqli_connect or not. At least one is not.
tip:
Access denied for user 'admin'@'localhost' (using password: NO)

Posted: Thu Aug 10, 2006 4:49 pm
by Obadiah
so what do i do? i dont mean to be a neusence but im new to the whole php deal and you said that its testing to see whether or not the password is correct...if i changed the password the error is the same...thats what i dont understand...if im thinking correctly its wanting to connect to mySQLadmin right...so if i put in the correct username and password it should work right? but its not....why?

and what did you mean by
volka wrote:My version tests, wether there are those variables you want to use with mysqli_connect or not. At least one is not.

Posted: Thu Aug 10, 2006 4:59 pm
by Ollie Saunders

Code: Select all

<?php
        $host = "localhost";
        $user = "admin";
        [[[[[[[[[[[$passwd]]]]]]]]]]]] = "admin";
        $database = "CustomerDirectory";
?>

Code: Select all

<?php
function Connect_to_db($filename)
{
        include($filename);
        $cxn = mysqli_connect($host,$user,[[[[[[[[[[[[$password]]]]]]]]]]]]]])
                or die ("Couldn't connect to server.");
        $db = mysqli_select_db($cxn,$database)
                or die ("Coulden't select database.");
}
?>
OK?

Posted: Fri Aug 11, 2006 12:56 am
by RobertGonzalez
Run a PHP info page...

Code: Select all

<?php
phpinfo();
?>
And look at the part where it says MySQL Client API Version. What does it say? What version of MySQL are you running?

Code: Select all

SELECT VERSION();
Please post back with that information.

Posted: Fri Aug 11, 2006 3:24 am
by volka
@Everah: The error message for that is "Client does not support authentication protocol" ;)

Posted: Fri Aug 11, 2006 8:51 am
by Obadiah
@Everah=the mysql version im using is 5.0.21

@ole= i understand what u are trying to say but if you would have read the message i wrote earlier to its completion you would have read that i tried to change the password to see if that would fix the problem and it didnt, and then i asked volka to explain the difference in the code that he wrote and the tutorial that i was following so that i could explain how it worked(thanx volka btw). Ive never worked with either of these languages (php and mySQL) before now so there is alot i dont understand and im following a tutorial that dosent cover debugging or error handling (and not to mention has alot of typos) to get a larger product for my company complete so the comment with the brackets around the password was hardly necessary.

Posted: Fri Aug 11, 2006 9:05 am
by Ollie Saunders
Obadiah: OK, Well I haven't been following this thread very closely I just saw that.

Posted: Fri Aug 11, 2006 9:08 am
by bmcewan
it is not the password per se that is the problem, but the password variable name, which is what ole was trying to point out.

Code: Select all

$passwd = "****";

Code: Select all

$cxn = mysqli_connect($host,$user,$password)
notice any difference?

EDIT: Took too long to finish my reply.

Posted: Fri Aug 11, 2006 9:29 am
by Obadiah
ok....i think i get it....but what password is it looking for is it looking for the mySQLadmin, the phpMYAdmin() bc thats where i created the database in....or am i still miles away from the answer...anyone? also if im thinking correctly the line

Code: Select all

if ( !isset($host,$user,$password,$database) )
is testing to see whether or not those variables are set. and in the file it points to somefile.php they are so thats why im not understanding. can someone explain to me what im doing wrong?

Posted: Fri Aug 11, 2006 9:36 am
by volka
Obadiah wrote:ok....i think i get it...
I'm not sure you did.
You noticed the difference
$passwd <- $passwd = "****";
$password <- mysqli_connect($host,$user,$password)
and have corrected that error?