if i want to check if database nikos_db exists is there a way to do it before the $db = DBI->connect("DBI:mysql:nikos_db", "root", "") method? because if i try to use this method first it cannot connect if the database doesnt exist! i need to check if databases exists before i try to connect to it and delete it! can you help me on that please? thanks!#!/usr/bin/perl -w use CGI::Carp qw(fatalsToBrowser); use CGI qw(:standard); use DBI; use DBD::mysql; print header( -charset=>"iso-8859-7" ); print start_html( -title=>"Ψυχωφελή Πνευματικά Κείμενα!", -background= +>"../data/images/night.jpg" ); $db = DBI->connect("DBI:mysql:nikos_db", "root", "") or $db = DBI->connect("DBI:mysql:nikos_db:50free.net", "nikos_db", "XXXXX +", {RaiseError=>1}); $db->do( "drop database if exists nikos_db"); $db->do( "create database nikos_db" );
Edit by castaway: X'd out possible password.
In reply to check if databse exists before connection is made! by Nik
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |