Jump to content

mySQL login tied to PHP code issues


Recommended Posts

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.

 

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.