Page 1 of 1

I couldn't create DB with this php code.

Posted: Wed Oct 27, 2010 12:23 am
by kchoi85
<?php

if ($dbc = mysql_connect('localhost', 'statgcom', 'M520choiw.')) {
print '<p> successfully connected to MySQL!</[>';


if (@mysql_query('CREATE DATABASE myblog')) {

print '<p> the database has been created!</p>';

} else {
print '<p> Failed to create DB
<br /> ' . mysql_error() . '.
</p>';
}

if (@mysql_select_db('myblog')) {
print '<p> the database has been selected.</p>';
} else {
print '<p> could not select the database because <br /> ' . mysql_error() . '.
</p>';
}

mysql_close(); // close connection

} else {

print '<p> could not connect to mysql <br /> ' . mysql_error() . '.
</p>';

}

?>

#################
The result was this


successfully connected to MySQL!
Failed to create DB
Access denied for user 'statgcom'@'localhost' to database 'myblog'.

could not select the database because
Access denied for user 'statgcom'@'localhost' to database 'myblog'.

###############################

Can you see the problem?
Thank you.

Re: I couldn't create DB with this php code.

Posted: Wed Oct 27, 2010 12:46 am
by iijb
hi,
Check your username and password for mysql is correct or not. I think there is a dot in your password.

Regards
iijb