$con = mysql_connect("bangla123.db.8390659.hostedresource.com","bangla123","Algnab123%");
if (!$con)
  die('Could not connect: ' . mysql_error());

if (mysql_query("CREATE DATABASE tryDB",$con))
  echo "Database created";
  echo "Error creating database: " . mysql_error();


When I run the code, i get error -"Error creating database:....

Pls advise.


Recommended Answers

All 4 Replies

Please use code tags when you include code.
Don't include your Database id and pw for your own protection.
Some web hosts don't allow you to create databases dynamically. You have to use their control panel / PHPMyAdmin. If that isn't a problem, then double-check that your db info is accurate.

Plz type the full mysql_error msg

Error creating database: Access denied for user 'bangla765'@'%' to database 'hh'

This means that your user account does not have the necessary privileges to create a database.Contact the administrator.Try to create the database using phpMyadmin or SQL YOG.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.