jokerofsouls Posted October 24, 2008 Share Posted October 24, 2008 I wanted to know how i could make a script that it will, look at the database and it will be yes or no if the table is or is not there, if you could please help. thanks Link to comment https://forums.phpfreaks.com/topic/130007-php-and-database-tables/ Share on other sites More sharing options...
wildteen88 Posted October 24, 2008 Share Posted October 24, 2008 Use the SHOW DATABASES sql command to get all the databases that currently exist. Then use a while loop to loop through the available databases, eg $sql = 'SHOW DATABASES'; $result = mysql_query($sql) or die ('MySQL Error: ' . mysql_error()); $my_database = 'YOUR DATABASE NAME'; while(list($db_name) = mysql_fetch_row($result)) { if($db_name == $my_database ) { echo $my_database . ' exists!'; } } Link to comment https://forums.phpfreaks.com/topic/130007-php-and-database-tables/#findComment-674042 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.