Hi
If this is verbatim code the connection string is inside the function and
the connection parameters are outside, so they will not be available to the
mysql_connect()
Try
function db_connect()
{
//Database Settings
$db_host = 'localhost'; //database hostname
$db_name = 'powerpla_powerplay'; //database name
$db_user = 'root'; //database USER name
$db_pass = 'rootpass'; // database password
if ($dbc = @mysql_connect($db_host,
$db_user, $db_pass)) {
if
(!mysql_select_db($db_name)) {
die('<p>Could not connect to the database because: <b>' . mysql_error() .
'</b></p>');
}
} else {
die('<p>Could not connect to the database because: <b>' . mysql_error() .
'</b></p>');
}
}
HTH
Peter
> -----Original Message-----
> From: Christian Biggins [mailto:[EMAIL PROTECTED]
> Sent: 26 January 2005 13:30
> To: 'Peter Lovatt'; [email protected]
> Subject: RE: Access denied for user - I cant work this out
>
>
> Hi Peter,
>
> There is a password being suppled - see code (btw, its local testing only,
> hence the root user)
>
> //Database Settings
> $db_host = 'localhost'; //database hostname
> $db_name = 'powerpla_powerplay'; //database name
> $db_user = 'root'; //database USER name
> $db_pass = 'rootpass'; // database password
>
> function db_connect()
> {
> if ($dbc = @mysql_connect($db_host,
> $db_user, $db_pass)) {
> if
> (!mysql_select_db($db_name)) {
>
> die('<p>Could not connect to the database because: <b>' . mysql_error() .
> '</b></p>');
> }
> } else {
>
> die('<p>Could not connect to the database because: <b>' . mysql_error() .
> '</b></p>');
> }
> }
>
>
>
> -----Original Message-----
> From: Peter Lovatt [mailto:[EMAIL PROTECTED]
> Sent: Thursday, 27 January 2005 12:27 AM
> To: Christian Biggins; [email protected]
> Subject: RE: Access denied for user - I cant work this out
>
> hi
>
> you are not passing a password to mysql - check your code to see
> if this is
> correct.
>
> Peter
>
> > -----Original Message-----
> > From: Christian Biggins [mailto:[EMAIL PROTECTED]
> > Sent: 26 January 2005 12:27
> > To: [email protected]
> > Subject: Access denied for user - I cant work this out
> >
> >
> > Hi All,
> >
> > I am consistently getting;
> >
> > Access denied for user: '[EMAIL PROTECTED]' (Using password: NO)
> >
> > I am connecting through php with the same script I use all the time, I
> > have checked it and dbl checked it for problems.
> >
> > I can connect to mysql in a prompt and I have added new users with all
> > priv's and connected with them - obviously its more a server issue
> > than mysql (I think)...
> >
> > MySQL version is 4.0.21
> > PHP Version 4.3.8
> > On a Win2k server using apache 2 (just a local testing server).
> >
> > Any info would be muchly appreciated.
> >
> > Christian
> >
> >
> > --
> > MySQL General Mailing List
> > For list archives: http://lists.mysql.com/mysql
> > To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
> >
>
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
>
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]