Jump to content

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


Cep

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.