phpmady Posted April 27, 2010 Share Posted April 27, 2010 Hi, I want to load the sample sql file in mysql, how to do in php Thank you Link to comment https://forums.phpfreaks.com/topic/199939-how-to-load-the-sql-file-in-mysql-in-php/ Share on other sites More sharing options...
masterwebxz Posted April 27, 2010 Share Posted April 27, 2010 Hi, I want to load the sample sql file in mysql, how to do in php Thank you something like this. $sql = file_get_contents($_FILES['file']); $sql = trim($sql); mysql_connect('localhost','root',''); mysql_select_db('test'); mysql_query($sql); Link to comment https://forums.phpfreaks.com/topic/199939-how-to-load-the-sql-file-in-mysql-in-php/#findComment-1049416 Share on other sites More sharing options...
phpmady Posted April 27, 2010 Author Share Posted April 27, 2010 Hi, I want to load the sample sql file in mysql, how to do in php Thank you something like this. $sql = file_get_contents($_FILES['file']); $sql = trim($sql); mysql_connect('localhost','root',''); mysql_select_db('test'); mysql_query($sql); Hi, this one creating db but not creating tables in db, whats am doing wrong Link to comment https://forums.phpfreaks.com/topic/199939-how-to-load-the-sql-file-in-mysql-in-php/#findComment-1049471 Share on other sites More sharing options...
phpmady Posted April 27, 2010 Author Share Posted April 27, 2010 Hi, I want to load the sample sql file in mysql, how to do in php Thank you something like this. $sql = file_get_contents($_FILES['file']); $sql = trim($sql); mysql_connect('localhost','root',''); mysql_select_db('test'); mysql_query($sql); Hi, this one creating db but not creating tables in db, whats am doing wrong thank You for ur hand, solved Link to comment https://forums.phpfreaks.com/topic/199939-how-to-load-the-sql-file-in-mysql-in-php/#findComment-1049477 Share on other sites More sharing options...
phpmady Posted April 27, 2010 Author Share Posted April 27, 2010 Hi, I want to load the sample sql file in mysql, how to do in php Thank you something like this. $sql = file_get_contents($_FILES['file']); $sql = trim($sql); mysql_connect('localhost','root',''); mysql_select_db('test'); mysql_query($sql); Hi, this one creating db but not creating tables in db, whats am doing wrong thank You for ur hand, solved Hi, I thought it was solved but still persists, i cannot load the file in mysql database,, pls give me ur hand whats am doing wrong, below is the code am using mysql_connect($hostname,$username,$password) or die(mysql_error()); //create the database here and pass down the statement $query = "CREATE DATABASE $dbname"; $result = mysql_query($query); mysql_select_db($dbname) or die(mysql_error()); $queryFile = 'cmstouch2.sql'; $sql1 = file_get_contents($queryFile); $sql = trim($sql1); $result = mysql_query($sql); if($result) { echo "sucess"; } else { echo "failed"; } thank You Link to comment https://forums.phpfreaks.com/topic/199939-how-to-load-the-sql-file-in-mysql-in-php/#findComment-1049509 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.