I have array with dynamic data and i need to create mysql table with array row[5] name. My code:
if(is_array($myarray)){
foreach ($myarray as $row) {
$val6 = mysqli_real_escape_string($db_conn, $row[5]);
$query ="CREATE TABLE $row[5] (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
USERNAME VARCHAR(30) NOT NULL,
EMAIL VARCHAR(40) NOT NULL,
DISCOUNT VARCHAR(5),
PASSW CHAR(128),
ROLE VARCHAR(9))";
mysqli_query($db_conn, $query);
}
}
I try it but return error:
Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''peter05' ( id INT(6) UNSIGNED AUTO_INCREMENT PRIM...' at line 1
i need to create a MariaDB table into foreach cycle with the name equal to the value of $row[5].
some idea?
............................................................