I am working on two platforms. One is a Windows 10 computer loaded with XAMPP, and the other is a Mac OS X El Capitan loaded with the default Apache, PHP and MySQL. The goal is to import an .sql file downloaded from a remote server to the local server. The codes are as follows:
$dbhost = 'localhost';
$dbuser = 'someuser';
$dbpass = 'somepassword';
$dbname = 'somedb';
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if ($mysqli->connect_error) {
die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
}
$filename = "somesql.sql";
$sqlSource = file_get_contents($filename);
$cmp = $mysqli->multi_query($sqlSource);
if($cmp){ $message = 'Import Successful'; }
else{ $message = 'Import Unsuccessful | '.$mysqli->error; }
However, the above codes work in XAMPP on the Windows 10 computer but not on the Mac OS X. In the Mac OS X, it somehow only executes the CREATE TABLE tablename
statement from the .sql file but not the INSERT INTO tablename VALUES bits. It does not yield any errors.
It also does not work in Windows with Apache, PHP and MySQL separately installed.
Is there something I missed or is there a configuration that I need to tweak to make it work on the Mac OS X?
Edit: Below is the generated sql file, somesql.sql:
CREATE TABLE `sometable` (
`id` smallint(9) unsigned NOT NULL AUTO_INCREMENT,
`var_1` varchar(200) DEFAULT NULL,
`var_2` varchar(200) DEFAULT NULL,
`var_3` varchar(200) DEFAULT NULL,
`int_1` int(100) DEFAULT NULL,
`int_2` int(100) DEFAULT NULL,
`int_3` int(100) DEFAULT NULL,
`text_1` text COMMENT 'depot address',
`text_2` text,
`text_3` text,
`decimal_1` decimal(10,2) DEFAULT NULL,
`decimal_2` decimal(10,2) DEFAULT NULL,
`decimal_3` decimal(10,2) DEFAULT NULL,
`datetime_1` datetime DEFAULT NULL,
`datetime_2` datetime DEFAULT NULL,
`datetime_3` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `var_1` (`var_1`)
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=latin1;
INSERT INTO sometable VALUES
("2","BN","","","","","","Some details","","","","","","","",""),
("3","MK","","","","","","Some other details","","","","","","","",""),
("4","CH","","","","","","Some other other details","","","","","","","","");