Cep Posted October 4, 2011 Share Posted October 4, 2011 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. 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) Quote Link to comment https://forums.phpfreaks.com/topic/248404-php-533-and-mysql-5-access-denied-for-user-userlocalhost/ Share on other sites More sharing options...
Pikachu2000 Posted October 4, 2011 Share Posted October 4, 2011 First, try using 'localhost' instead of the IP:port address and see if the results are different. Quote Link to comment https://forums.phpfreaks.com/topic/248404-php-533-and-mysql-5-access-denied-for-user-userlocalhost/#findComment-1275610 Share on other sites More sharing options...
Cep Posted October 4, 2011 Author Share Posted October 4, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/248404-php-533-and-mysql-5-access-denied-for-user-userlocalhost/#findComment-1275620 Share on other sites More sharing options...
PFMaBiSmAd Posted October 4, 2011 Share Posted October 4, 2011 Slightly off topic (isn't likely to be causing the error), but the 4th parameter of mysql_connect() is not the database name. Quote Link to comment https://forums.phpfreaks.com/topic/248404-php-533-and-mysql-5-access-denied-for-user-userlocalhost/#findComment-1275624 Share on other sites More sharing options...
dougjohnson Posted October 4, 2011 Share Posted October 4, 2011 Example: $db = mysql_connect("localhost", "dummy", "password") or die("Could not connect: " . mysql_error()); mysql_select_db("dbname",$db) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/248404-php-533-and-mysql-5-access-denied-for-user-userlocalhost/#findComment-1275626 Share on other sites More sharing options...
Cep Posted October 4, 2011 Author Share Posted October 4, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/248404-php-533-and-mysql-5-access-denied-for-user-userlocalhost/#findComment-1275633 Share on other sites More sharing options...
Cep Posted October 5, 2011 Author Share Posted October 5, 2011 Ok so really bizarre, I turn the server on today and it all works? No code changes, nothing. I'll chalk this up to a mystery cache or Windows process. Quote Link to comment https://forums.phpfreaks.com/topic/248404-php-533-and-mysql-5-access-denied-for-user-userlocalhost/#findComment-1276075 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.