Jump to content

mysql query issue


Imaulle

Recommended Posts

Hello,

 

The following code will correctly import the sql file when the database is 'database' but if the code is ran again and the database is 'database1' (because 'database' is taken) the sql file will not be imported. any ideas?

 

 

$a = file_get_contents('https://'.$username.':'.$password.'@localhost:2083/frontend/x3/sql/adduser.html?user=user&pass=password');
mysql_connect('localhost', $username.'_user' , 'password');

$counter = '';

do{
$database='databse'.$counter;
$db=mysql_select_db($username.'_'.$database);
$counter++;
}while($db);


$a = file_get_contents('https://'.$username.':'.$password.'@localhost:2083/frontend/x3/sql/addb.html?db='.$database);
$a = file_get_contents('https://'.$username.':'.$password.'@localhost:2083/frontend/x3/sql/addusertodb.html?user='.$username.'_user&db='.$username.'_'.$database.'&ALL=ALL');

$db = mysql_select_db($username.'_'.$database);

$file = fopen('database.sql', 'r');
$temp = '';
while($line = fgets($file)){
if ((substr($line, 0, 2) != '--') && (substr($line, 0, 2) != '/*') && (substr($line,0,1) != '#') && (strlen($line) > 1)){$last = trim(substr($line, -2, 1));
$temp .= trim(substr($line, 0, -1));
if ($last == ';'){
mysql_query($temp);
$temp = '';
}
}
}
fclose($file);

Link to comment
https://forums.phpfreaks.com/topic/238804-mysql-query-issue/
Share on other sites

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.