Imaulle Posted June 8, 2011 Share Posted June 8, 2011 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 More sharing options...
Imaulle Posted June 8, 2011 Author Share Posted June 8, 2011 nevermind it was an issue with cPanel >_< Link to comment https://forums.phpfreaks.com/topic/238804-mysql-query-issue/#findComment-1227110 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.