コマンドラインなしでphpスクリプトを考えてデータをダンプしようとしました。このスクリプトで.sql ファイルを作成してから、スクリプトを試します。
$link = mysql_connect($host, $user, $pass);
mysql_select_db($name, $link);
$sqlFile = 'sql.sql';
$fsize = filesize($sqlFile);
$fopen = fopen($sqlFile, 'r');
$fread = fread($fopen, $fsize);
fclose($fopen);
mysql_query($fread) or die(mysql_error());
mysql_close();
データをダンプしようとすると、エラーが発生しました:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TABLE `ps_access` (`id_profile` int(10) unsigned NOT NULL,`id_tab` int(10' at line 1
しかし、SQL を phpMyAdmin の SQL 入力タブに貼り付けると、この SQL コードに問題はありません。
DROP TABLE IF EXISTS `ps_access`;
CREATE TABLE `ps_access` (
`id_profile` int(10) unsigned NOT NULL,
`id_tab` int(10) unsigned NOT NULL,
`view` int(11) NOT NULL,
`add` int(11) NOT NULL,
`edit` int(11) NOT NULL,
`delete` int(11) NOT NULL,
PRIMARY KEY (`id_profile`,`id_tab`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
それでは、phpスクリプトのエラーはどこにあり、データをダンプするように修正する方法は?
平均SQLファイルは約800KB
敬具、ジョージ!