Associate
Hi Everyone, I am trying to create some tables automatically using this code:
If I plug this directly into mySQL as a copy pasta then it executes no problem, however trying to run this as a php script throws:
Does anyone have any ideas, I assume it's something to do with the space I have been the two table queries?
TIA!
Code:
function initial_create_tables() {
$query = "
CREATE TABLE dContent (
dContentID int NOT NULL AUTO_INCREMENT,
title text,
text text,
linkName text,
specialInclude int,
PRIMARY KEY(dContentID)
);
CREATE TABLE sContent (
sContentID int NOT NULL AUTO_INCREMENT,
description text,
value text,
inputType int,
PRIMARY KEY(sContentID)
);
CREATE TABLE admin (
adminID int NOT NULL AUTO_INCREMENT,
adminUser text,
adminPass text,
PRIMARY KEY(adminID)
); ";
if ($this->mysqli->query($query)) {
return "Table creation success!";
}
else {
return $this->mysqli->error;
}
}
If I plug this directly into mySQL as a copy pasta then it executes no problem, however trying to run this as a php script throws:
Code:
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 sContent ( sContentID int NOT NULL AUTO_INCREMENT, descr' at line 8
Does anyone have any ideas, I assume it's something to do with the space I have been the two table queries?
TIA!