Ciao a tutti
Io ho bisogno di prendere tutto il testo(sche sarebbero i comandi sql) da un file e poi fare la query al db.
Quindi prelevo il testo:
codice:
$sql_file[0] = "prova.sql";
$handle = fopen( $sql_file[0], "r" );
$query = fread( $handle, filesize($sql_file[0]));
fclose($handle);
e ho quindi nella variabile $query il seguente testo:
codice:
DROP TABLE IF EXISTS prova,
CREATE TABLE prova (
equipaggiamento_id INT(6) UNSIGNED not null AUTO_INCREMENT,
equipaggiamento_nome VARCHAR (255) not null ,
equipaggiamento_peso DECIMAL (5,2),
equipaggiamento_costo INT (5),
equipaggiamento_tipo VARCHAR (255) not null ,
equipaggiamento_desc text NOT NULL,
PRIMARY KEY (equipaggiamento_id)
)
eseguiro' ora la query:
codice:
mysql_query($query, $db_connect) or die("Errore nella query: " . mysql_error());
ma mi da questo errore che non riesco a capire cosa sia:
codice:
Errore nella query: 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 prova ( equipaggiamento_id INT(6) UNSIGNED not null AUTO_INCREMEN' at line 3
Sapete aiutarmi?
tnx