mylifeservices Posted May 7, 2010 Share Posted May 7, 2010 Greetings, I am new to the PHP and mySQL world. I am receiving an error upon unsuccessful login. The error is: "Access denied for user 'INTERNET-SERVER$'@'localhost' (using password: NO)" This is the conn.php include file. <? /* // 'server' 'database_username' 'database_password' $connection = mysql_connect("localhost", "****", "******") or die (mysql_error()); // 'database_name' $db = mysql_select_db("exam_final", $connection) or die (mysql_error()); */ $server="localhost"; $database="exam_final"; $user="****"; $password="*****"; // /* $server="localhost"; $database="exam_final"; $user="****"; $password="*****"; */ mysql_connect($server,$user,$password); mysql_select_db($database); ?> Any thoughts, pointers, or anything should be helpful. Quote Link to comment Share on other sites More sharing options...
Mchl Posted May 7, 2010 Share Posted May 7, 2010 Do you use correct username and password, and does the user you're connecting as have appropriate privileges? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 7, 2010 Share Posted May 7, 2010 It would really help if you provided some line number information about where the error is occurring at. For all we can tell, you are actually getting that error for a mysql_query() statement because your actual msyql_connect() is either failing or the include statement for the file it is in is failing. Quote Link to comment Share on other sites More sharing options...
mylifeservices Posted May 7, 2010 Author Share Posted May 7, 2010 Thank you for the help. Users do have correct privledges. Also, mentioned was line number. Can someone please direct me to a document to learn how this is done. Quote Link to comment Share on other sites More sharing options...
Mchl Posted May 7, 2010 Share Posted May 7, 2010 Full error message should look like: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'INTERNET-SERVER$'@'localhost' (using password: NO) in /path/to/file.php on line 3 At the end the should be a filename and a line number, where error occured. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 7, 2010 Share Posted May 7, 2010 I'm going to guess that you are attempting to develop and debug your php code on a system where error_reporting/display_errors are not set to show you all the errors php detects. For debugging purposes (remove them when you are done and you should actually have these two setting in your master php.ini so that fatal parse errors are displayed too), add the following two lines of code immediately after the first opening <?php tag in your main file - ini_set("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment Share on other sites More sharing options...
mylifeservices Posted May 7, 2010 Author Share Posted May 7, 2010 Thanks for the help. Here is what came back: Warning: include(admin/include/conn.php) [function.include]: failed to open stream: No such file or directory in D:\websites\dirtydogmedia.com\admin\login.php on line 8 Warning: include() [function.include]: Failed opening 'admin/include/conn.php' for inclusion (include_path='.;c:\php\includes') in D:\websites\dirtydogmedia.com\admin\login.php on line 8 Warning: mysql_query() [function.mysql-query]: Access denied for user 'INTERNET-SERVER$'@'localhost' (using password: NO) in D:\websites\dirtydogmedia.com\admin\login.php on line 12 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in D:\websites\dirtydogmedia.com\admin\login.php on line 12 Access denied for user 'INTERNET-SERVER$'@'localhost' (using password: NO) The 'admin/include/conn.php' file exists. Also, at the top of the thread is the conn.php file. Any further ideas? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 7, 2010 Share Posted May 7, 2010 The 'admin/include/conn.php' file exists. Yes, but not relative to where login.php is located at. Login.php is in the admin folder. By using include('admin/include/conn.php') in login.php you are asking for the file to exist in admin/admin/include/conn.php Use include/conn.php Edit: You are also apparently attempting to develop php code on a live server. That wastes a huge amount of your time due to the constant uploading of files. You should be developing php code on a local development system and only put it onto a live server once you have it 100% tested. Quote Link to comment Share on other sites More sharing options...
mylifeservices Posted May 7, 2010 Author Share Posted May 7, 2010 Ok, this fixed a couple of the warnings. Here is what s left. Warning: mysql_query() [function.mysql-query]: Access denied for user 'INTERNET-SERVER$'@'localhost' (using password: NO) in D:\websites\dirtydogmedia.com\admin\login.php on line 12 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in D:\websites\dirtydogmedia.com\admin\login.php on line 12 Access denied for user 'INTERNET-SERVER$'@'localhost' (using password: NO) Here is line 12 in login.php $result = mysql_query($strQuery) or die(mysql_error()); I guess it died Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 7, 2010 Share Posted May 7, 2010 That means you don't have a connection at the time the mysql_query() was executed. Based on the short open tag you posted <? in the conn.php code, your server is not setup to use the optional short open tags. Be constant and write code that will always be seen as php code by only using full opening <?php tags, they always work, whereas you will always be chasing down php.ini settings to get short open tags to work every time you switch servers or someone updates php on your server. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.