I put my files on my server, but I'm unable to connect to the database. My project works on my local machine, but not on my production server.
I'm using mysql and php.
I'm getting this error:
[01-Nov-2010 18:27:01] PHP Warning: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Access denied for user 'dbuser'#'localhost' (using password: YES) in /home/mysite/public_html/zendamf_remote_quiz/MyData.php on line 20
[01-Nov-2010 18:27:01] PHP Warning: mysql_select_db() [<a href='function.mysql-select-db'>function.mysql-select-db</a>]: Access denied for user 'mysite'#'localhost' (using password: NO) in /home/mysite/public_html/zendamf_remote_quiz/MyData.php on line 21
[01-Nov-2010 18:27:01] PHP Warning: mysql_select_db() [<a href='function.mysql-select-db'>function.mysql-select-db</a>]: A link to the server could not be established in /home/mysite/public_html/zendamf_remote_quiz/MyData.php on line 21
[01-Nov-2010 18:27:01] PHP Warning: mysql_query() [<a href='function.mysql-query'>function.mysql-query</a>]: Access denied for user 'mysite'#'localhost' (using password: NO) in /home/mysite/public_html/zendamf_remote_quiz/MyData.php on line 28
[01-Nov-2010 18:27:01] PHP Warning: mysql_query() [<a href='function.mysql-query'>function.mysql-query</a>]: A link to the server could not be established in /home/mysite/public_html/zendamf_remote_quiz/MyData.php on line 28
[01-Nov-2010 18:27:01] PHP Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/mysite/public_html/zendamf_remote_quiz/MyData.php on line 31
[01-Nov-2010 18:27:01] PHP Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/mysite/public_html/zendamf_remote_quiz/MyData.php on line 46
Does this error mean that my password is incorrect? Any suggestions?
Thank you.
-Laxmidi
Either your user or password is wrong (or even your server, but that's more rare).
Be aware that there are two users on that stacktrace, 'dbuser' and 'mysite', could be related to that?
Thank you for the help. I made a dumb error. My host prefaces the user name and the database name with the site's user name in order to avoid conflicts. I forgot about that.
Related
i cannot install opencart on third step.i have the following problem:
Warning: mysqli::mysqli(): (HY000/1045): Access denied for user
'root'#'localhost' (using password: NO) in
C:\wamp\www\opencart\upload\system\library\db\mysqli.php on line
7Warning: DB\MySQLi::__construct(): Couldn't fetch mysqli in
C:\wamp\www\opencart\upload\system\library\db\mysqli.php on line
10Warning: DB\MySQLi::__construct(): Couldn't fetch mysqli in
C:\wamp\www\opencart\upload\system\library\db\mysqli.php on line
10Notice: Undefined variable: mysql in
C:\wamp\www\opencart\upload\install\controller\install\step_3.php on
line 280Notice: Trying to get property of non-object in
C:\wamp\www\opencart\upload\install\controller\install\step_3.php on
line 280
php× 1144494
If someone is getting same type of error ,you could try out this,
username=admin
password=
keep your password null
The reason this might happened is because of password you gave in phpmyadmin during setting time.
I have a custom application written on php, which is connecting with database. If I run it on the windows wamp server the application is connect correct with the database. If I run it on the ubuntu apache2 i am getting the following error:
<b>Warning</b>: mysqli::real_connect(): (28000/1045): Access denied for user 'user'#'localhost'
(using password: YES) in <b>/var/www/html/reportCMS/php/classes/Database.class.php</b> on line <b>137
</b><br />
<br />
<b>Warning</b>: mysqli::set_charset(): invalid object or resource mysqli
in <b>/var/www/html/reportCMS/php/classes/Database.class.php</b> on line <b>141</b><br />
<br />
<b>Warning</b>: mysqli::prepare(): invalid object or resource mysqli
in <b>/var/www/html/reportCMS/php/classes/Database.class.php</b> on line <b>829</b><br />
<br />
<b>Fatal error</b>: Problem preparing query (SELECT id,username,password,type from user WHERE BINARY
username=? AND active=1 ) Access denied for user 'user'#'localhost' (using password: YES) in <b
>/var/www/html/reportCMS/php/classes/Database.class.php</b> on line <b>830</b><br />
And the Database.class.php line 137 is:
$this->_mysqli = mysqli_init();
$this->_mysqli->real_connect( $this->host, $this->username, $this->password, $this->db, $this->port );
$this->_mysqli->set_charset ('utf8');
The connection with database in both cases, is on the ubuntu machine with mysql.
Can you guide me, how to find the error? If you need more information please tell me.
EDIT:
The only difference is on the config file for the permissions, which on the ubuntu is localhost. And on the windows machine is the IP of the ubuntu. But I have grant the permission both for localhost and % on the mysql.
EDIT2:(for the # anant kumar singh suggestion)
Warning: mysqli::real_connect(): (HY000/1045): Access denied for user 'user'#'myip' (using password: NO) in C:\wamp\www\reportCMS\php\classes\Database .class.php on line 138
Warning: mysqli::set_charset(): invalid object or resource mysqli in C:\wamp\www\reportCMS\php\classes\Database.class.php on line 142
Warning: mysqli::prepare(): invalid object or resource mysqli in C:\wamp\www\reportCMS\php\classes\Database.class.php on line 830
Fatal error: Problem preparing query (SELECT id,username,password ,type from user WHERE BINARY username=? AND active=1 ) Access denied for user 'user'#'myip (using password: NO) in C:\wamp\www\reportCMS\php\classes\Database.class.php on line 831
Finally I solved it. My mistake was that the config file(username, password, db) is created on Windows. Because of that there some whitespaces insert on the file, I remove it from the Ubuntu with the Netbeans and it worked.
$connection1 = mysql_connect($servername,$username,$password);
$db1 = mysql_select_db($dbname,$connection1);
some html and php code here
$connection2 = mysql_connect($servername1,$username1,$password1);
$db2 = mysql_select_db($dbname1,$connection2);
Error:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user '*****'#'***.com' (using password: YES) in /home/
Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /home/
Warning: mysql_query() [function.mysql-query]: Access denied for user '******'#'********' (using password: NO) in /home/
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/
I get this error when i want to fetch something or try to connect
You have to add IP address from your hosting cpanel at option Remove MySQL to allow remote access.
http://go.wlg.co.nz/login.php
I had a page working fine and I swear I didn't change anything. Now its returning this:
Warning: mysql_connect() [function.mysql-connect]: Can't connect to
local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in
/home/content/93/10501493/html/go/connect.php on line 15
Warning: mysql_select_db() expects parameter 2 to be resource, boolean
given in /home/content/93/10501493/html/go/connect.php on line 16
Warning: mysql_real_escape_string() expects parameter 2 to be
resource, boolean given in /home/content/93/10501493/html/go/login.php
on line 16
Warning: mysql_real_escape_string() expects parameter 2 to be
resource, boolean given in /home/content/93/10501493/html/go/login.php
on line 17
Warning: mysql_close() expects parameter 1 to be resource, boolean
given in /home/content/93/10501493/html/go/connect.php on line 18
Anything obvious jumps out?
Make sure mysql service is running
service mysqld start
Or
Are you connecting to "localhost" or "127.0.0.1" ? when you connect to "localhost" the socket connector is used, but when you connect to "127.0.0.1" the TCP/IP connector is used. You could
try using "127.0.0.1" if the socket connector is not enabled/working.
How might php can connect to serial Comm?
I try use a class php_serial.class.php but that does not work, when I run the web, error occurs
Warning: Specified serial port is not valid in D:\POS\AppServ\www\Eri\ulikan\phptoserial\gagal\php_serial.class.php on line 111
Warning: The device must be set before to be open in D:\POS\AppServ\www\Eri\ulikan\phptoserial\gagal\php_serial.class.php on line 137
Warning: Device must be opened in D:\POS\AppServ\www\Eri\ulikan\phptoserial\gagal\php_serial.class.php on line 541
Warning: Device must be opened to read it in D:\POS\AppServ\www\Eri\ulikan\phptoserial\gagal\php_serial.class.php on line 474
Warning: Unable to set the baud rate : the device is either not set or opened in D:\POS\AppServ\www\Eri\ulikan\phptoserial\gagal\php_serial.class.php on line 204