Code: Select all
// database_name is a unique client identifier
mysql_query("CREATE DATABASE `$database_name`;");
// get the sql
$sql = file_get_contents("base-sql.txt");
// create a new connection for this
$connection_2 = mysql_connect("localhost", 'myUsername "myPassword") or die("oh crap...");
mysql_select_db($database_name) or die("Time for tea");
// okay, lets do it --- So far I've
mysql_query($sql, $connection_2);
if (mysql_error()) {
echo "Error #: ". mysql_errno() . "<br />" . mysql_error();
echo "<br /><br /><h1>Base sql</h1>";
echo "<textarea>$sql</textarea>";
die();
exit();
}The sql seems fine...Error #: 1064
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 IF NOT EXISTS `headers` ( `id` int(11) NOT NULL aut' at line 5
Code: Select all
CREATE TABLE IF NOT EXISTS `headers` (
`id` int(11) NOT NULL auto_increment,
`url` text,
`username` varchar(255) default NULL,
`password` varchar(255) default NULL,
`title` varchar(255) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;I should mention that the SQL is quite a bit longer than that, but I've only been able to get one query to run out of the 50 or so there (thought I haven't tried all of them.. I did try exploding it and running the query that way, but....:
Code: Select all
CREATE TABLE `customers` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) default NULL,
`home_phone` varchar(255) default NULL,
`cell_phone` varchar(255) default NULL,
`work_phone` varchar(255) default NULL,
`email` varchar(255) default NULL,
`website` varchar(255) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=latin1;I'm stumped, help me please!!!