aboutera Posted August 17, 2011 Share Posted August 17, 2011 This is a code to create a database <?php $con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } if (mysql_query("CREATE DATABASE my_db",$con)) { echo "Database created"; } else { echo "Error creating database: " . mysql_error(); } mysql_close($con); ?> and that is the error I am getting : Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'peter'@'localhost' (using password: YES) in C:\wamp\www\New folder\iji.php on line 2 Could not connect: Access denied for user 'peter'@'localhost' (using password: YES) Please help Quote Link to comment https://forums.phpfreaks.com/topic/245042-a-total-noob-here/ Share on other sites More sharing options...
AyKay47 Posted August 17, 2011 Share Posted August 17, 2011 sounds like your mysql_connect credentials are incorrect.. double check the credentials and keep character casing in mind.. Quote Link to comment https://forums.phpfreaks.com/topic/245042-a-total-noob-here/#findComment-1258620 Share on other sites More sharing options...
aboutera Posted August 17, 2011 Author Share Posted August 17, 2011 sounds like your mysql_connect credentials are incorrect.. double check the credentials and keep character casing in mind.. could you explain more please ? how to check these credentials? thank you Quote Link to comment https://forums.phpfreaks.com/topic/245042-a-total-noob-here/#findComment-1258621 Share on other sites More sharing options...
Carbon Posted August 17, 2011 Share Posted August 17, 2011 sounds like your mysql_connect credentials are incorrect.. double check the credentials and keep character casing in mind.. could you explain more please ? how to check these credentials? thank you $con = mysql_connect("localhost","peter","abc123"); You need to make sure you change 'peter' to your username and 'abc123' to your password you have set for mysql. Quote Link to comment https://forums.phpfreaks.com/topic/245042-a-total-noob-here/#findComment-1258623 Share on other sites More sharing options...
coder_ Posted August 17, 2011 Share Posted August 17, 2011 Could it be that you forgot to set mysql credentials so only default are valid? Try with this: user: root pass: - (leave this empty) Quote Link to comment https://forums.phpfreaks.com/topic/245042-a-total-noob-here/#findComment-1258626 Share on other sites More sharing options...
aboutera Posted August 17, 2011 Author Share Posted August 17, 2011 Could it be that you forgot to set mysql credentials so only default are valid? Try with this: user: root pass: - (leave this empty) Thanks guys it worked ! Quote Link to comment https://forums.phpfreaks.com/topic/245042-a-total-noob-here/#findComment-1258661 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.