PHP error
#1

Warning: mysql_connect(): Access denied for user 'charlesp'@'localhost' (using password: YES) in /home/firstga1/public_html/global/class/SQL.php on line 30
Could not connect: Access denied for user 'charlesp'@'localhost' (using password: YES)


<?php
/*$host="localhost";
$username="cp";
$password="chuJUstabR2XA3";
$host="ns2.kloud51.com";
$username="ngrp";
$password="@phh63oo3";
$db_name="NGRP";*/

/* Windows Box
DEFINE('HOST', 'eu9.hostskool.com');
DEFINE('USRNM', 'charlesp');
DEFINE('PSWD', '****');
DEFINE('DBNM', 'charlesp');
*/

// Linux Box
DEFINE('HOST', 'eu9.hostskool.com');
DEFINE('USRNM', 'charlesp');
DEFINE('PSWD', '*****');
DEFINE('DBNM', 'charlesp');

/*
DEFINE('HOST', 'eu9.hostskool.com');
DEFINE('USRNM', 'charlesp');
DEFINE('PSWD', '*****');
DEFINE('DBNM', 'charlesp');
*/

mysql_connect("127.0.0.1", "charlesp", "******") or die('Could not connect: ' . mysql_error());
mysql_select_db("charlesp") or die('Could not connect: ' . mysql_error());
?>
Reply
#2

You have to make sure you are using the correct MYSQL details.
Reply
#3

The script looks fine, except from this piece on top "?php" which should obviously be "<?php".

Furthermore, MySQL_* is deprecated and shouldn't be used anymore, I recommend you to use PDO or MySQLi. MySQL can't be used anymore from PHP 6.0 I believe, meaning your scripts won't run when this version becomes the standard. MySQLi has an excellent way of procedural programming, just like MySQL has, but I personally recommend PDO because it supports more database engines and in my opinion it's better overall.
Reply
#4

Quote:
Originally Posted by JasperM
Посмотреть сообщение
The script looks fine, except from this piece on top "?php" which should obviously be "<?php".

Furthermore, MySQL_* is deprecated and shouldn't be used anymore, I recommend you to use PDO or MySQLi. MySQL can't be used anymore from PHP 6.0 I believe, meaning your scripts won't run when this version becomes the standard. MySQLi has an excellent way of procedural programming, just like MySQL has, but I personally recommend PDO because it supports more database engines and in my opinion it's better overall.
i conver it to pdo new error :

SQLSTATE[HY000] [2002] Connection timed outSELECT `id`, `Username`, `IP`, `SecureIP`, `AdminLevel`, `Helper`, `ReferredBy` FROM `accounts` WHERE `Username` = ''Invalid query: Access denied for user ''@'localhost' (using password: NO)
Reply
#5

Your credentials are wrong. Make sure you use the correct details when you make the code.
Reply
#6

Quote:
Originally Posted by SaltySandy
Посмотреть сообщение
Your credentials are wrong. Make sure you use the correct details when you make the code.
Код:
$admquery = "SELECT `id`, `Username`, `IP`, `SecureIP`, `AdminLevel`, `Helper`, `ReferredBy` FROM `accounts` WHERE `Username` = '$myusername'";

$admincheckquery = mysql_query($admquery);

if (!$admincheckquery) {

	echo $admquery;

	die('Invalid query: ' . mysql_error());
Reply
#7

Fill in the details of your connection correctly. They are wrong.
Reply
#8

Quote:

SQLSTATE[HY000] [2002] Connection timed outSELECT `id`, `Username`, `IP`, `SecureIP`, `AdminLevel`, `Helper`, `ReferredBy` FROM `accounts` WHERE `Username` = ''Invalid query: Access denied for user ''@'localhost' (using password: NO)
Your database haven't a password.
Then, in the connection string leave password parameter as blank.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)