ho visto ke alcuni script hanno un bel file setup ke crea in automatico database e tabelle..
ma ke sintassi devo seguire??..mi postate qlke esempio?
ho visto ke alcuni script hanno un bel file setup ke crea in automatico database e tabelle..
ma ke sintassi devo seguire??..mi postate qlke esempio?
[ SimplyMepis 8 ]Copyleft
www.mepisitalia.org IL SITO ITALIANO UFFICIALE DI MEPIS
www.salentomovida.it LA MOVIDA DEL SALENTO HA UN NUOVO PUNTO D'INCONTRO SUL WEB
[ SUD SOUND SYSTEM MINA FUECU INTRA ALLU SALENTU ]
Beh, lo puoi fare con mphpmyadmin, devi fare il dump del database che ti serve e salvi tutto il contenuto in un file.sql
parli di file .sql?
lo scrivi come se facessi tanti comandi SQL e verranno eseguiti tutti quando scriverai da DOS: (o linux)
codice:mysql < prova.sql > errori.txt![]()
ok..facciamo finta ke io abbia
ma il database lo devo creare sempre cn phpmyadmin??Codice PHP:
# phpMyAdmin SQL Dump
# version 2.5.3
# [url]http://www.phpmyadmin.net[/url]
#
# Host: localhost
# Generato il: 15 Giu, 2004 at 03:08 PM
# Versione MySQL: 4.0.15
# Versione PHP: 4.3.3
#
# Database : `negozio`
#
# --------------------------------------------------------
#
# Struttura della tabella `ditta`
#
CREATE TABLE `ditta` (
`id` int(11) NOT NULL auto_increment,
`nome` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=4 ;
#
# Struttura della tabella `fatture`
#
CREATE TABLE `fatture` (
`id` int(11) NOT NULL auto_increment,
`nfatt` text NOT NULL,
`articolo` text NOT NULL,
`desc` longtext NOT NULL,
`um` text NOT NULL,
`quant` double NOT NULL default '0',
`prezzo` double NOT NULL default '0',
`sconto` double NOT NULL default '0',
`importo` double NOT NULL default '0',
`aliquota` int(11) NOT NULL default '0',
`ditta` text NOT NULL,
`pagato` text NOT NULL,
`giorno` text NOT NULL,
`mese` text NOT NULL,
`anno` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=34 ;
#
# Struttura della tabella `incassi`
#
CREATE TABLE `incassi` (
`id` int(11) NOT NULL auto_increment,
`incasso` int(11) NOT NULL default '0',
`giorno` text NOT NULL,
`mese` text NOT NULL,
`anno` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=5 ;
#
# Struttura della tabella `note`
#
CREATE TABLE `note` (
`id` int(11) NOT NULL auto_increment,
`giorno` text NOT NULL,
`mese` text NOT NULL,
`anno` text NOT NULL,
`testo` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=7 ;
# --------------------------------------------------------
#
# Struttura della tabella `riepilogo`
#
CREATE TABLE `riepilogo` (
`id` int(11) NOT NULL auto_increment,
`nfatt` text NOT NULL,
`tq` double NOT NULL default '0',
`tim` double NOT NULL default '0',
`tiv` double NOT NULL default '0',
`tfa` double NOT NULL default '0',
`pagato` text NOT NULL,
`giorno` text NOT NULL,
`mese` text NOT NULL,
`anno` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=16 ;
# --------------------------------------------------------
#
# Struttura della tabella `um`
#
CREATE TABLE `um` (
`id` int(11) NOT NULL auto_increment,
`nome` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=6 ;
[ SimplyMepis 8 ]Copyleft
www.mepisitalia.org IL SITO ITALIANO UFFICIALE DI MEPIS
www.salentomovida.it LA MOVIDA DEL SALENTO HA UN NUOVO PUNTO D'INCONTRO SUL WEB
[ SUD SOUND SYSTEM MINA FUECU INTRA ALLU SALENTU ]
te l'ho appena detto, lo fai con mysql!Originariamente inviato da alex86
ma il database lo devo creare sempre cn phpmyadmin??
![]()
e qual'è la sintassi??..
il codice lo devo mettere sempre nel file ke o postato prima??
[ SimplyMepis 8 ]Copyleft
www.mepisitalia.org IL SITO ITALIANO UFFICIALE DI MEPIS
www.salentomovida.it LA MOVIDA DEL SALENTO HA UN NUOVO PUNTO D'INCONTRO SUL WEB
[ SUD SOUND SYSTEM MINA FUECU INTRA ALLU SALENTU ]
Originariamente inviato da alex86
e qual'è la sintassi??..
il codice lo devo mettere sempre nel file ke o postato prima??
fai tutto con php.
il file .sql è una sequenza di istruzioni SQL per creare le tabelle che serviranno successivamente allo script.
il tuo setup.php non sarà altro che un'esecuzione di questi comandi:
...
$sql="CREATE TABLE `ditta` (
`id` int(11) NOT NULL auto_increment,
`nome` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=4 ;";
mysql_query($sql) or die("errore");
....
think simple think ringo
nn sto capendo...
ho fatto sto file setup.php
ma nn funziona..mi dà errore alla seconda lineaCodice PHP:
<?
CREATE DATABASE `negozio`;
# phpMyAdmin SQL Dump
# version 2.5.3
# [url="http://www.phpmyadmin.net"][url]http://www.phpmyadmin.net[/url][/url]
#
# Host: localhost
# Generato il: 15 Giu, 2004 at 03:08 PM
# Versione MySQL: 4.0.15
# Versione PHP: 4.3.3
#
# Database : `negozio`
#
# --------------------------------------------------------
#
# Struttura della tabella `ditta`
#
CREATE TABLE `ditta` (
`id` int(11) NOT NULL auto_increment,
`nome` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=4 ;
#
# Struttura della tabella `fatture`
#
CREATE TABLE `fatture` (
`id` int(11) NOT NULL auto_increment,
`nfatt` text NOT NULL,
`articolo` text NOT NULL,
`desc` longtext NOT NULL,
`um` text NOT NULL,
`quant` double NOT NULL default '0',
`prezzo` double NOT NULL default '0',
`sconto` double NOT NULL default '0',
`importo` double NOT NULL default '0',
`aliquota` int(11) NOT NULL default '0',
`ditta` text NOT NULL,
`pagato` text NOT NULL,
`giorno` text NOT NULL,
`mese` text NOT NULL,
`anno` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=34 ;
#
# Struttura della tabella `incassi`
#
CREATE TABLE `incassi` (
`id` int(11) NOT NULL auto_increment,
`incasso` int(11) NOT NULL default '0',
`giorno` text NOT NULL,
`mese` text NOT NULL,
`anno` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=5 ;
?>
[ SimplyMepis 8 ]Copyleft
www.mepisitalia.org IL SITO ITALIANO UFFICIALE DI MEPIS
www.salentomovida.it LA MOVIDA DEL SALENTO HA UN NUOVO PUNTO D'INCONTRO SUL WEB
[ SUD SOUND SYSTEM MINA FUECU INTRA ALLU SALENTU ]
mi correggo...scusate!
ma mi diceCodice PHP:
<?
// parametri del database
$db_host = "localhost";
$db_user = "root";
$db_password = "";
$db_name = "negozio";
$sql="CREATE DATABASE `negozio`";
mysql_query($sql) or die("errore");
# phpMyAdmin SQL Dump
# version 2.5.3
# [url="http://www.phpmyadmin.net"][url]http://www.phpmyadmin.net[/url][/url]
#
# Host: localhost
# Generato il: 15 Giu, 2004 at 03:08 PM
# Versione MySQL: 4.0.15
# Versione PHP: 4.3.3
#
# Database : `negozio`
#
# --------------------------------------------------------
#
# Struttura della tabella `ditta`
#
$sql="CREATE TABLE `ditta` (
`id` int(11) NOT NULL auto_increment,
`nome` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=4";
mysql_query($sql) or die("errore");
#
# Struttura della tabella `fatture`
#
$sql = "CREATE TABLE `fatture` (
`id` int(11) NOT NULL auto_increment,
`nfatt` text NOT NULL,
`articolo` text NOT NULL,
`desc` longtext NOT NULL,
`um` text NOT NULL,
`quant` double NOT NULL default '0',
`prezzo` double NOT NULL default '0',
`sconto` double NOT NULL default '0',
`importo` double NOT NULL default '0',
`aliquota` int(11) NOT NULL default '0',
`ditta` text NOT NULL,
`pagato` text NOT NULL,
`giorno` text NOT NULL,
`mese` text NOT NULL,
`anno` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=34";
mysql_query($sql) or die("errore");
#
# Struttura della tabella `incassi`
#
$sql="CREATE TABLE `incassi` (
`id` int(11) NOT NULL auto_increment,
`incasso` int(11) NOT NULL default '0',
`giorno` text NOT NULL,
`mese` text NOT NULL,
`anno` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=5";
mysql_query($sql) or die("errore");
?>
Warning: mysql_query(): Accesso non consentito per l'utente: 'ODBC@localhost' (Password: NO) in c:\programmi\easyphp1-7\www\negozio\setup.php on line 9
Warning: mysql_query(): A link to the server could not be established in c:\programmi\easyphp1-7\www\negozio\setup.php on line 9
errore
[ SimplyMepis 8 ]Copyleft
www.mepisitalia.org IL SITO ITALIANO UFFICIALE DI MEPIS
www.salentomovida.it LA MOVIDA DEL SALENTO HA UN NUOVO PUNTO D'INCONTRO SUL WEB
[ SUD SOUND SYSTEM MINA FUECU INTRA ALLU SALENTU ]
Originariamente inviato da alex86
ma nn funziona..mi dà errore alla seconda linea
così non può funzionare. devi eseguire con php le istruzioni SQL:
mysql_query("CREATE....") or die("errore");
think simple think ringo