File Doesn't Work in Virtual Server - php

I have a PHP file called footer10.php that worked just fine in shared hosting. I moved it to a virtual server and it no longer works.
I get these errors when I pull the file up in a browser:
Warning: mysql_query() [function.mysql-query]: Access denied for user 'apache'#'localhost' (using password: NO) in /var/www/.../...com/httpdocs/.../footer10.php on line 23
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /var/www/.../...com/httpdocs/.../footer10.php on line 23
Access denied for user 'apache'#'localhost' (using password: NO)
This is on line 23 of the file:
$presult = mysql_query("SELECT COUNT(*) FROM submission") or die(mysql_error());
Any idea what I need to do to make the file work on the virtual server?
Thanks in advance,
John

The error message means that PHP could not connect to the MySQL database.
If you're establishing the connection on your own using mysql_connect you should make sure that host, user and password are correct (according to the error message no password was specified)
The user name and the empty password makes me think you've relied on the mysql.default_* settings on your old server. You can specify a default server in your php.ini, refer to the manual for this. The connection will then be opened automatically by php.
So what you have to do is to find out correct credentials for your MySQL server. Then you either establish a connection using mysql_connect/mysql_pconnect or add it to the php.ini.

Access denied for user 'apache'#'localhost' (using password: NO) , what does this line mean ?
It means you need to update you're mysql connection settings with the correct ones ( username , password and host ) by this i mean you're mysql connection settings on the new server are different than the ones on the old server . Then make shure to move the database from one server to another .

Related

MySQL Error - Php

When I go to the page, I get 4 errors, but when I execute the script it works perfectly and once it reloads the page after the scirpt has executed the errors go away. And the thing is I am using a password to connect and I am not connecting to localhost.
Warning: mysql_query() [function.mysql-query]: Access denied for user 'a1160699'#'localhost' (using password: NO) in /home/a1160699/public_html/stockupdate/index.php on line 16
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/a1160699/public_html/stockupdate/index.php on line 16
Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'a1160699'#'localhost' (using password: NO) in /home/a1160699/public_html/stockupdate/index.php on line 17
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/a1160699/public_html/stockupdate/index.php on line 17
This error indicates that you have invalid MySQL credentials - either the user does not exist, or the password you're using is wrong. It appears that you're not using any password, so you might have just missed to input the password.
In case the username and password are correct, you should make sure that this user has the necessary permissions to interact with this database.
Warning: mysql_query() [function.mysql-query]: Access denied for user
'a1160699'#'localhost' (using password: NO) in
/home/a1160699/public_html/stockupdate/index.php on line 16
This line is indicating that your user you have set in your connection array does not have the required permissions and/or does not exist on the server you are attempting to run your code on. You will need to check that the username and password matches one that has the correct permissions on your MySQL server.
EDIT
<?php
$username="a1160699";
$password="passwordHere";
$database="a1160699_rsg4s";
mysql_connect("mysql3.000webhost.com", $username, $password);
mysql_select_db($database) or die( "Unable to select database");
?>
Try this code in your connect.php file. This is MySQL to fit your code but I would strongly suggest you look at MySQLi or PDO.
If you are using a password for the localhost server then please connect your application in localhost server like this.
mysql_connect('localhost','root','your passwrd');
mysql_select_db('your databse name');
After you can execute your query to database then it will work fine..

Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'#'localhost' (using password: NO)

I'm using XAMPP on Windows 7. and when I try to open a login.php of current project
I get this error
Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'#'localhost' (using password: NO) in E:\xampplite\htdocs\newfule\mcp\clientlist.php on line 19
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in E:\xampplite\htdocs\newfule\mcp\clientlist.php on line 19
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in E:\xampplite\htdocs\newfule\mcp\clientlist.php on line 21
Sorry No entries for the Records of Student ......
this is config file
<?php
$link = mysql_connect('127.0.0.1', 'root', '');
if (!$link) {
die('Not connected : ' . mysql_error());
}
// make foo the current db
$db_selected = mysql_select_db('fueldb', $link);
if (!$db_selected) {
die ('Can\'t use foo : ' . mysql_error());
}
?>
This is one warning is at phpmyadmin
Using phpmyadmin you cannot have a user with an empty password which instead is allowed in mysql.
The error doesn't seem to be in the config file. ODBC is the default user when none is specified, so since everything seems good in the config file it appears it's either not being included before the call to mysql_query or that the mysql_query call itself is being done wrong.
Without more code there's no real way to know.
i think you don't have problem with config file.i think problem with adding a config file or including a config file.i suggest u to check link that include or add config file.
Use localhost instead of 127.0.0.1
127.0.0.1 uses TCP instead of unix sockets
Also stop using mysql for PHP. It has been removed. Use mysqli or pdo
Your error and your config file are not appling the same users
Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'#'localhost' (using password: NO)
Error about query the user "ODBC" from host "localhost"
mysql_connect('127.0.0.1', 'root', '');
Connecting with the user 'root' to '127.0.0.1'
¿Is your configuration applied? It seems that "clientlist.php" is using other $link resource
Also take in cosideration that the users in mysql user table contains by default the host reference. This meants that root#localhost could be correct to access without password but root#127.0.0.1 could be denied.
You could view in the user table of the "mysql" database the registered users, if they have password and the host (or hosts) allowed. Each user could appear more than once if the host is different. Also is possible to use the character "%" in the host to allow all hosts or a subnet (but i dont recommend this for production environments)
In all cases is recommended to create a proper user and assing privileges to the desired database to operate it.
try to given access table to user :
grant all On [tabelName] to [userName];
example
grant all On mysql.* to root;

Error while connecting to mysql database from php

I have recently started exploring free hosting sites where they provide free mysql and php.
I have created a database and trying to connect to the database from php script. But while running the php. I am getting following error :
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'a1696486_test '#'localhost' (using password: YES) in /home/a1696486/public_html/myphp/test1.php on line 2
Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'a1696486'#'localhost' (using password: NO) in /home/a1696486/public_html/myphp/test1.php on line 3
Any idea whats the problem ?
Regards,
Shankar
I have this issue on our dedicated servers, and the solution for me is to provide the fully qualified domain name rather than 'localhost'. For exmaple, my connection is:
mysqli_connect('dedi81.jnb1.host-h.net', 'user', 'pass', 'db');
Where even though localhost is the same as dedi81.jnb1.host-h.net (MySQL server and web server on one machine) I - for some reason - cannot use 'localhost'.
Another issue may be that on the hosting company you're with, they have not granted to you the correct permissions, or that there is indeed an error with the username and / or password.
You can also try and substitute 'localhost' with the IP address of the MySQL machine.
Kind regards,
Simon

php5 and mysql5 on windows server

I have installed php5 and mysql5 on my server , I can login to mysql from command,
but when I try to connect using php I got this error message:
Access denied for user 'root'#'localhost' (using password: YES)PHP Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'#'localhost' (using password: NO) in D:\HostingSpaces\law-training\lawtraining.ir\wwwroot\includes\class.php on line 279 PHP Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in
I dont use 'ODBC'#'localhost' in my code at all.
I check using phpmyadmin , also I can't use it and can't connect to server.I use port 3309 for mysql , and from local or remote php can't login.
I use also mysql4 on this server on port 3306 and I can use it without problem.
how can i fix this problem?
Thanks
Try logging in to localhost:3309, I think you'll find that you're running it on a non-standard port, so you need to tell PHP where to look for the server.
ie.
mysql_connect("localhost:3309", "root", "mypassword");
As a sidenote, the ODBC#localhost connection is what mysql_query tries to use if there's no connection already open.
Is this a brand new MySQL 5 installation, and you have no means to log into it? You may want to reset the root password.
http://dev.mysql.com/doc/refman/5.1/en/resetting-permissions.html
That should enable you to access MySQL using the command line. Then, make sure you have a root#localhost user and grant the relevant permissions to that user. For example:
mysql> GRANT ALL PRIVILEGES ON . TO 'root'#'localhost'
-> IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
If the problem persists with odbc connections, make sure your odbc data access product is fully compatible with your version of MySQL 5.x
Regards,
Netrista Khatam
Technical Services Manager
OpenLink Product Support

mysql_connect() is not getting to the correct server

I have a system with a globally open mysql connection to the local server. In one of my files I am opening an additional connection to a remote machine.
Wieldly instead of trying to connect to that machine, I get an access denied message from my ISP (it seems to be trying to connect to the database on that machine).
I am trying to connect using:
$cust_conn = mysql_connect($host,'root','##password##');
I have tried subdomain.domain.com:3306, subdomain.domain.com and ip:3306 as the value for $host.
The wierd this is the response i get:
Warning: mysql_connect(): Access denied for user 'root'#'my.isp.com' (using password: YES) in /var/www/html/report/module/sql_view.php on line 19 Error: Could not connect to database:
Any ideas why this would happen? It seems like for some reason my script is attempting to connect to my ISPs server, instead of the one passed in $host.
The host given in the error message is the host it's trying to connect from, not to.
that hostname in the error (my.isp.com) is your client's host...remote root access is often disabled, or perhaps the pass/host combo is wrong
to add the creds:
http://dev.mysql.com/doc/refman/5.1/en/adding-users.html

Categories