Hi!
I wrote this little peace of code, which is supposed to check if a certain database exists, and if not, create one.
(Maybe there's a much better way to do it, but I don't know it)
Anyway, here's the code:
use DBI;
$username = 'root';$password = '';$database = 'tina'; $hostname = '';
if (!($dbh = DBI->connect("dbi:mysql:database=$database;" .
"host=$hostname;port=3306", $username, )))
{
$result=`mysqladmin -u root create tina`;
print "Creating dabase...\n";
}
Basically, it's doing what I wanted, but on top of creating a database, it still prints out the error:
DBI connect('database=tina;host=;port=3306','root',...) failed: Unknown database 'tina'
Is there a way I can avoid that error being printed out?
I wrote this little peace of code, which is supposed to check if a certain database exists, and if not, create one.
(Maybe there's a much better way to do it, but I don't know it)
Anyway, here's the code:
use DBI;
$username = 'root';$password = '';$database = 'tina'; $hostname = '';
if (!($dbh = DBI->connect("dbi:mysql:database=$database;" .
"host=$hostname;port=3306", $username, )))
{
$result=`mysqladmin -u root create tina`;
print "Creating dabase...\n";
}
Basically, it's doing what I wanted, but on top of creating a database, it still prints out the error:
DBI connect('database=tina;host=;port=3306','root',...) failed: Unknown database 'tina'
Is there a way I can avoid that error being printed out?