I´m looking that i have another problem: I´m making a software to install in any server. The software needs a database, so i want to create a script install.php to create the database when this script is executed. At this point of the instalation, i don´t know none of the users that are defined in mysql. If i use this command: mysql_query("CREATE DATABASE my_db",$con) first i need to connect to mysql with the command mysql_connect But at this point, i don´t know none of the users that are defined in mysql. So, what i do in this case? Thanks On Mon, Feb 9, 2009 at 12:31 PM, Shawn McKenzie <nospam@xxxxxxxxxxxxx>wrote: > Shawn McKenzie wrote: > > R B wrote: > >> Hello, > >> > >> When i create a mysql database with the next command: > >> > >> mysql_query("CREATE DATABASE my_db",$con) > >> > >> In the server is created the database, but usually the name is created > with > >> a prefix. > >> > >> In this case: someuser_my_db > >> > >> How can i detect with PHP the complete name of the new database created? > >> > >> Thanks > >> > > > > There may be a better way, but off the top of my head, translate this to > > PHP: > > > > use information_schema; > > select SCHEMA_NAME from SCHEMATA where SCHEMA_NAME like '%_my_db'; > > > > Now of course you could have multiples there, like user_my_db and > > user2_my_db. Not sure about that, maybe it would be the last one in the > > returned records? > > > > Using mysql_list_dbs() and mysql_db_name() would acheive the same, > however from the man page of mysql_db_name() there is a neat contib: > > $result = mysql_query("SELECT DATABASE()"); > $dbname = mysql_result($result, 0); > > -- > Thanks! > -Shawn > http://www.spidean.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >