ShadowIce Posted November 23, 2009 Share Posted November 23, 2009 Hi all. I'm new here. Could someone please tell me how to fix this database exists code so it works w/ the $db variable, OR show me a code that you CAN check if a CERTAIN database exists? I need to be able to check a certain database to see whether or not it exists. function CheckDatabase ($db=false) { $result = mysql_list_dbs ($this -> connection); While ($list = mysql_fetch_array($result)) { $database_list[] = $list['database']; } if (in_array($this -> database, $database_list)) { echo $database_list; return true; } else { return false; } } ANY help would be GREATLY appreciated! =) Thanks! =) Shadow~ Link to comment https://forums.phpfreaks.com/topic/182666-please-help-need-help-w-database_exists-function/ Share on other sites More sharing options...
ShadowIce Posted November 23, 2009 Author Share Posted November 23, 2009 Thanks guys! =) Link to comment https://forums.phpfreaks.com/topic/182666-please-help-need-help-w-database_exists-function/#findComment-964090 Share on other sites More sharing options...
mikesta707 Posted November 23, 2009 Share Posted November 23, 2009 you should set error reporting to all ini_set("display_errors", 1); error_reporting(E_ALL); it should be $row['Database'] not database. Link to comment https://forums.phpfreaks.com/topic/182666-please-help-need-help-w-database_exists-function/#findComment-964101 Share on other sites More sharing options...
ShadowIce Posted November 23, 2009 Author Share Posted November 23, 2009 Now its complaining about the $this-connection line. how can i fix this? function CheckDatabase ($db=false) { $result = mysql_list_dbs ($this -> connection); While ($list = mysql_fetch_array($result)) { $database_list[] = $list['Database']; } if (in_array($this -> Database, $database_list)) { return true; } else { return false; } } Link to comment https://forums.phpfreaks.com/topic/182666-please-help-need-help-w-database_exists-function/#findComment-964134 Share on other sites More sharing options...
ShadowIce Posted November 23, 2009 Author Share Posted November 23, 2009 Some assistance would be great on this matter! thank you! ^^ Link to comment https://forums.phpfreaks.com/topic/182666-please-help-need-help-w-database_exists-function/#findComment-964138 Share on other sites More sharing options...
ShadowIce Posted November 23, 2009 Author Share Posted November 23, 2009 Another code that does the same thing but better might work better for me. Link to comment https://forums.phpfreaks.com/topic/182666-please-help-need-help-w-database_exists-function/#findComment-964179 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.