Jump to content

PLEASE HELP! Need help w/ database_exists() function...


ShadowIce

Recommended Posts

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~

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;

}


}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.