I have ran into a wall with trying to connect to my site now it worked fine till I added a shoutbox but I don't think it has caused it to run into a Access denied for user 'www-data'#'localhost' (using password: NO).
I have several sites running and only this one site seems to be running into this problem I have reset password and still no luck please someone help me.
config.php
$site_settings['mysql_host'] = "localhost";
$site_settings['mysql_user'] = "root";
$site_settings['mysql_pass'] = "PasswordHash";
$site_settings['mysql_db'] = "project";
cms.php
function dbconn()
{
global $site_settings;
if (!#mysql_connect($site_settings['mysql_host'], $site_settings['mysql_user'], $site_settings['mysql_pass']))
{
switch (mysql_errno())
{
case 1040:
case 2002:
if ($_SERVER['REQUEST_METHOD'] == "GET")
die("<html><head><meta http-equiv='refresh' content=\"5 $_SERVER[REQUEST_URI]\"></head><body><table border='0' width='100%' height='100%'><tr><td><h3 align='center'>The server load is very high at the moment. Retrying, please wait...</h3></td></tr></table></body></html>");
else
die("Too many users. Please press the Refresh button in your browser to retry.");
default:
die("[" . mysql_errno() . "] dbconn: mysql_connect: " . mysql_error());
}
}
mysql_select_db($site_settings['mysql_db'])
or die('dbconn: mysql_select_db: ' . mysql_error());
mysql_set_charset('utf8');
}
screenshot - http://prntscr.com/b7nnc7
P.S I have gotten error_reporting(E_ALL); intact also.
Related
Hi i have a problem connecting with my Mysql database i have the following code:
<?php
$servername = "dt5.ehb.be";
$username = "TVOSAPP";
$password = "*****";
$dbname = "TVOSAPP";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT storyId, title, score FROM Stories";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo "id: " . $row["storyId"]. "Naam" . $row["title"]. "score" . $row["score"]. "<br>";
}
} else {
echo "0 results";
}
mysqli_close($conn);
?>
which gives the following error:
Connection failed: Access denied for user 'TVOSAPP'#'10.3.101.30' (using password: YES)
I hope you can help me out to solve this problem it would be very much appreciated
the user that you are trying to connect with might not have the permission to connect remotely to the DB. please verify the same. To give remote access you might need to run
grant <privilage name> on TVOSAPP.* to 'TVOSAPP'#'<youripaddress>' identified by <yourpassword>
Ref: http://dev.mysql.com/doc/refman/5.7/en/grant.html
EDIT:
If your IP address is not static then you can use a percentage sign (%) in place of your IP address. However this approach is less secure as it allows any host to connect to the database remotely.
I fixed it about a week ago is had a space too much thats why I couldn't connect thank you all for your responses
Perl codes always connecting to same MySQL(local but in error showing FQDN of server) database although it is configured to connect to different server.
please see the codes.
$datasetname="DBI:mysql:database=applications;host=entdb"
$$dbobject = DBI -> connect ($datasetname, $username, $password,
{RaiseError => 0, PrintError => 0})
or $errflg2 = 1;
print TT (" : ".time()."\n");
close (TT);
if ($errflg2 > 0)
{
$errmsg = "ERROR opening up the database: $datasetname\n";
$errmsg .= " Error number: " . $DBI::err . "\n";
$errmsg .= " Error text : " . $DBI::errstr . "\n";
print "$errmsg";
ilog ($ifile, $errmsg);
mail_it ($errmsg);
if ($debug != 0) { close (DB); }
exit (1);
}
else
{ print "Opened the '" . $datasetname . "' database.\n"; }**
enter code here
error
ERROR opening up the database: DBI:mysql:database=applications;host=entdb
Error number: 1045
Error text : Access denied for user 'entdb'#'vpl121' (using password: YES)
see in code i referred entdb, but Perl connecting to VPL121. Perl codes are running on vpl121.
In mysql all user accounts are identified via username#hostname format, where hostname is the host name or ip address of the computer from which the code connects to the mysql database.
You did write that the perl code runs on vpl121, therefore this is the hostname that mysql uses. Apparently, you do not have any user account that matches the 'entdb'#'vpl121' or the password is incorrect or the given user does not have access to the entdb database.
My guess is that you do not have any matching user accounts. Consider perhaps creating an 'entdb'#'%' user account, where % as hostname stands for any host name or ip address.
Warning: mysql_connect(): (HY000/2002): Connection refused in
/home/vol14_1/byethost31.com/b31_16461744/htdocs/Mysql/con.php on line
7
Warning: mysql_select_db(): No such file or directory in
/home/vol14_1/byethost31.com/b31_16461744/htdocs/Mysql/con.php on line
8
Warning: mysql_select_db(): A link to the server could not be
established in
/home/vol14_1/byethost31.com/b31_16461744/htdocs/Mysql/con.php on line
8
I have the below code
<?php
$localhost="localhost";
$username=b31_16461744;
$pass=test123;
$dbname=b31_16461744_user;
$a= mysqli_connect($localhost,$user,$pass);
mysql_select_db($dbname);
if($a)
{
echo "connected..";
}
else
{
echo "not...!!";
}
?>
Sidenote: Assuming the credentials are correct, given to you by your web host.
There are several problems with this code (taken from a comment you left).
Firstly, three of your declarations are not quoted and are being treated as constants.
PHP error reporting would have thrown notices of undefined constants.
These are treated as constants:
$username=b31_16461744;
$pass=test123;
$dbname=b31_16461744_user;
You are also referencing the wrong variable for the username being $user which should be $username. Error reporting would have signabled an undefined variable notice.
Then you're mixing mysql_ with mysqli_ syntax. Those different MySQL APIs do NOT intermix. You must use the same one throughout your code.
Sidenote: The other question you posted Access denied for user 'test123'#'192.168.0.38' (using password: NO) you are using sql306.byethost31.com for the host. Make sure that is correct. I have no idea what settings that host wants you to use.
<?php
$localhost="localhost";
$username="b31_16461744";
$pass="test123";
$dbname="b31_16461744_user";
$a= mysqli_connect($localhost, $username, $pass);
mysqli_select_db($a, $dbname);
if($a)
{
echo "connected..";
}
else
{
echo "not...!!";
}
?>
or just use all four parameters:
<?php
$localhost="localhost";
$username="b31_16461744";
$pass="test123";
$dbname="b31_16461744_user";
$a= mysqli_connect($localhost, $username, $pass, $dbname);
if($a)
{
echo "connected..";
}
else
{
echo "not...!!" . mysqli_error($a);
}
?>
However, your else with the echo does not help you. Use mysqli_error() to get the real error.
I.e.: or die("Error " . mysqli_error($a));
Example from the manual
$link = mysqli_connect("myhost","myuser","mypassw","mydb")
or die("Error " . mysqli_error($link));
References:
http://php.net/manual/en/function.error-reporting.php
http://php.net/manual/en/mysqli.error.php
http://php.net/manual/en/function.mysqli-connect.php
http://php.net/manual/en/language.constants.php
Add error reporting to the top of your file(s) which will help find errors.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// rest of your code
Sidenote: Displaying errors should only be done in staging, and never production
I Think Credentials are not correctly set. See Your connection statement.
For Reference :
While Working On Localhost, We write connection statement as :
$con=mysql_connect("localhost","root","");
$db1=mysql_select_db("DatabaseName",$con);
But, While working on server, we need to change the following credential.
Username and password values are must.
$con=mysql_connect("localhost","Username","password");
$db1=mysql_select_db("DatabaseName",$con);
i created a simple db connection in my php page and its working fine since its not showing any error while executing this
<?php
$link = mysql_connect('www.ccccccccccccc.co.uk', 'cccccccccc', 'accccc');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
/*echo 'Connected successfully';*/
echo "DB : <font color='green'>ACTIVE</font>";
mysql_close($link);
?>
The problem is the page is showing error Access denied for user 'root'#'localhost' (using password: NO) while executing
<?php
$q = mysql_query("SELECT slno, name, idno FROM $memlist") or die(mysql_error());
echo "<table><tr><th> NO</th><th> NAME</th>
<th> ID NO</th></tr>";
while($row = mysql_fetch_array($q)){
extract($row);
echo "<tr><td>$slno</td><td>$name</td>
<td>$idno</td></tr>";
}
echo"</table>";
?>
i am working on server directly not on local host
You don't appear to be connecting to the database in the second piece of code, so it's trying to connect with default settings (which obviously won't be correct due to security concerns).
As for the first block of code, you're closing the connection immediately after opening it, which is kind of pointless.
I'm trying to connect to a remote database. Here's my code:-
php $con = mysql_connect("2toria.com","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db("myTable", $con);
$result = mysql_query("SELECT * FROM Contestants");
while($row = mysql_fetch_array($result)) { echo $row['Name']; echo "<br />"; }
mysql_close($con);
The database, table, username and password names are all correct (I've changed them here for obvious reasons), but I'm getting the following error:-
Warning: mysql_connect() [function.mysql-connect]: Access denied for
user 'username'#'bluechip6.ukhost4u.com' (using password: YES) in
/home/toriaco/public_html/bigbro/index.php on line 9 Could not
connect: Access denied for user 'username'#'bluechip6.ukhost4u.com'
(using password: YES)**
First possible reason:
I know antagonist (a Dutch hosting service) blocks all connections that are not from localhost for security reasons, and I don't think they are the only ones. (So always connect to localhost, not a http://... URL!)
Second possible reason:
The password/username is wrong.