Jump to content

PHP 5.3.3 and MySQL 5: Access denied for user 'user'@'localhost'


Recommended Posts

Hi,

 

I am getting frustrated beyond belief at the moment with trying to get a very simple script to run, I am using PHP 5.3.3 and MySQL 5.1 on a Win2k8 server with IIS7.5. Basically my script is connecting to a local database, running a single select query, returning those rows and building up a string from them.

 

The problem is that I am receiving complete BS responses from PHP that the access is denied for the user being specified. This is complete rubbish since the user can connect via mysql, sqlyog, ASP.NET MVC without issue but for some bizarre reason it is not working via PHP. :facewall:

 

The code for the script is here :

 

<?php

$mysql = mysql_connect('127.0.0.1:3306', 'myuser', 'mypass', 'mydatabase');


if (!$mysql) {
  die(mysql_error());
  $content = "<nobr></nobr>";
} else {
  
  $result = mysql_query('SELECT * FROM tblEventGroup'); 
  $content = "<nobr>";
  
  if ($result) {     
      while($row = mysql_fetch_assoc($result)) {
      	$content .= "<span>";
      	$content .= $row['GroupName'];
      	$content .= "</span>";
      	$content .= "<a href=\"../Event/EventSearch?groupid=";
      	$content .= $row['GroupId'];
      	$content .= "\" target=\"_blank\">Book here</a> ";
      }
  }
  
  mysql_close($mysql);
  $content .= "</nobr>";

}

?>

 

I cannot for the life of me understand what the problem is, the return error is

 

Access denied for user 'myuser'@'localhost' (using password: YES)

Unfortuantely I have tried "localhost", "machine name", "127.0.0.1". I have then tried all of them with the port number appended as well. I have even tried to connect with the Mysql Root user and even this is denied. :(

Hi,

 

Well spotted, I am used to using mysqli you see! Anyhow I have removed that from my code but I receive the same error. I have re-granted permissions to the users in Mysql and flushed them again but still no luck. You do not think this has anything to do with IIS 7.5 do you?

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.