Does anyone have a generic script that asks the user Database name, Password, Server and than will import an sql file? Looking to build an installation for a mysql database. Thanks!
No funds at the moment - sorry. Just looking for pointers. I found Micro DB Installer but you need the DB already created. Looking for something that does it all.
class database { var $host; var $username; var $password; var $dbLink; var $queryResult; //Constructor function database($host,$username,$password) { $this->host=$host; $this->username=$username; $this->password=$password; } //Utility Functions function dbLoad($name) { $this->dbLink = mysql_connect($this->host,$this->username,$this->password); if (!$this->dbLink) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully<br>'; // make foo the current db $db_selected = mysql_select_db($name, $this->dbLink); if (!$db_selected) { die ("Can't use $name : " . mysql_error()); } else { echo "Found the Database $name"; } } function dbQuery($query) { //$query = sprintf("SELECT firstname, lastname, address, age FROM friends WHERE firstname='%s' AND lastname='%s'", //mysql_real_escape_string($firstname), //mysql_real_escape_string($lastname)); // Perform Query $result = mysql_query($query); // Check result // This shows the actual query sent to MySQL, and the error. Useful for debugging. if (!$result) { $message = '<BR>Invalid query: ' . mysql_error() . "\n<BR>"; $message .= 'Whole query: ' . $query; if(preg_match('/Duplicate entry/si',$message,$tempMatch)<>1) { die($message); } else { echo "<br>Not Halting Since Duplicate: ".$message; } } return $result; } }//END OF CLASS**************************************************************** PHP: Here is a class I made for accessing a database, I always include it in my projects. Here is an example of how to use it function createDataTables(&$database) { $database->dbQuery("CREATE TABLE wiki_entry_table(id INT NOT NULL AUTO_INCREMENT,entity_name TEXT(30),address TEXT,first_paragraph TEXT,PRIMARY KEY (id),UNIQUE INDEX entity_name( entity_name( 30 ) ))"); echo '<BR>Table wiki_entry_table Created'; $database->dbQuery("CREATE TABLE data_table(id INT,attribute TEXT,value TEXT)"); echo '<BR>Table data_table Created'; } PHP: This is a createDataTables function I made, that is activated when $_GET['install']=1, you could just do something like this