dink87522 Posted November 9, 2008 Share Posted November 9, 2008 I have setup a php file with: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?php mysql_connect("localhost", "dink87522_dink", "dink8752_password") or die(mysql_error()); echo "Connected to MySQL<br />"; ?> </body> </html> On the server I have setup a mysql db with username dink (so in full it is dink87522_dink) and the relevant password. However when I upload it, it fails to connect, any reason why? Quote Link to comment https://forums.phpfreaks.com/topic/132069-solved-mysql-connect/ Share on other sites More sharing options...
premiso Posted November 9, 2008 Share Posted November 9, 2008 Whats the error message it is giving? If it is on your own box, test that the mysql page is started and that the username has been created. If you provide the error message it should tell you which it is. Quote Link to comment https://forums.phpfreaks.com/topic/132069-solved-mysql-connect/#findComment-686289 Share on other sites More sharing options...
dink87522 Posted November 9, 2008 Author Share Posted November 9, 2008 Error message: " Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'dink87522_dink'@'localhost' (using password: YES) in /www/oxyhost.com/d/i/n/dink87522/htdocs/test.php on line 10 Access denied for user 'dink87522_dink'@'localhost' (using password: YES)" However I have given myself the permissions. Quote Link to comment https://forums.phpfreaks.com/topic/132069-solved-mysql-connect/#findComment-686296 Share on other sites More sharing options...
dink87522 Posted November 9, 2008 Author Share Posted November 9, 2008 This is a screenshot of my db setup in mysq http://img393.imageshack.us/my.php?image=90051463lh9.jpg Quote Link to comment https://forums.phpfreaks.com/topic/132069-solved-mysql-connect/#findComment-686298 Share on other sites More sharing options...
premiso Posted November 9, 2008 Share Posted November 9, 2008 This is really a mysql issue. In the mysql console you have to use the GRANT TO option: http://dev.mysql.com/doc/refman/5.0/en/grant.html GRANT ALL ON *.* TO 'dink87522_dink'@'localhost'; That would grant all access, you can also specify it for just a single database which is more secure. Given that setup, I would contact your host support and ask why. It could be something in their code, or you could be doing something wrong. Either way it is nearly impossible for us to help you with this issue. Quote Link to comment https://forums.phpfreaks.com/topic/132069-solved-mysql-connect/#findComment-686300 Share on other sites More sharing options...
.josh Posted November 9, 2008 Share Posted November 9, 2008 mysql_connect("localhost", "dink87522_dink", "dink8752_password") or die(mysql_error()); Usually database passwords do not have the prefix attached to them, so unless you physically set your password to be like that, take off the db prefix on your password. And if for some reason your db does that, or you did it yourself, I notice you are have ...22_ on the user but ...2_ on the pw prefix. Perhaps one of these things is the issue? Quote Link to comment https://forums.phpfreaks.com/topic/132069-solved-mysql-connect/#findComment-686325 Share on other sites More sharing options...
dink87522 Posted November 10, 2008 Author Share Posted November 10, 2008 I tried both of those although it still will not work. Quote Link to comment https://forums.phpfreaks.com/topic/132069-solved-mysql-connect/#findComment-686348 Share on other sites More sharing options...
dink87522 Posted November 10, 2008 Author Share Posted November 10, 2008 Thanks for all the help just got it working. Username was "dink87522_dink" however password was then just 'password' without the dink87522 prefix, so its a bit weird. Quote Link to comment https://forums.phpfreaks.com/topic/132069-solved-mysql-connect/#findComment-686355 Share on other sites More sharing options...
.josh Posted November 10, 2008 Share Posted November 10, 2008 Thanks for all the help just got it working. Username was "dink87522_dink" however password was then just 'password' without the dink87522 prefix, so its a bit weird. That was the first thing I suggested, which you said didn't work...anyhow, glad you got it working. Quote Link to comment https://forums.phpfreaks.com/topic/132069-solved-mysql-connect/#findComment-686362 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.