The reason for the error lies within this line:
This lines thells php to split the content of
$schema on each "\n" php finds in the string.
The query you posted is definietely a multiline query, therefore it will be split over several array-items (
$sqls is an array). Basically you will be running queries like these:
SQL Code:
DROP TABLE IF EXISTS `phpdesk_admin`
next query:
SQL Code:
CREATE TABLE `phpdesk_admin` (
next query:
SQL Code:
`id` int(255) NOT NULL DEFAULT '0',
and so on.
As you can see, only the first query is correctly formatted, and correct syntax, and will therefor be run. The others will rresult in an error right away as it's completely invalid syntax.
Instead of splitting on "\n" (newlines), you should be splitting per query.
I'm not 100% sure, but I thought you could use
mysqli_query to execute several queries at the same time. That way you could simply pass on the data in the .sql file, and run it on your server.
Or..., and this is probably the best way, you could run the following query: