check is a database exists?

check is a database exists?

am 18.11.2006 03:23:42 von laredotornado

Hi, Using MySQL 5.0 and PHP 4.4.4, what is the easiest way (using PHP
code) to check if a database by a particular name exists?

Thanks, - Dave

Re: check is a database exists?

am 19.11.2006 02:56:47 von nc

laredotornado@zipmail.com wrote:
>
> Using MySQL 5.0 and PHP 4.4.4, what is the easiest way (using PHP
> code) to check if a database by a particular name exists?

Get a list of existing databases using mysql_list_dbs() and see if the
name you are interested in is on the list:

http://www.php.net/manual/en/function.mysql-list-dbs.php

Cheers,
NC