Bruno,

> I do not succeed to create of the tables using php follows listing
> ciao.
> <?php
> # FileName="Connection_php_mysql.htm"
> # Type="MYSQL"
> # HTTP="true"
> $hostname_connLiceo = "localhost";
> $database_connLiceo = "maresped";
> $username_connLiceo = "bruno";
> $password_connLiceo = "pamela";
> $connLiceo = mysql_connect($hostname_connLiceo, $username_connLiceo,
> $password_connLiceo) or die(mysql_error());
> $select = mysql_select_db("maresped");
> $SQL = CREATE TABLE utenti (
> IDUtente INT(4) AUTO_INCREMENT PRIMARY KEY,
> Nome CHAR(30) NOT NULL,
> Cognome CHAR(30) NOT NULL,
> Indirizzo CHAR(50),
> Citta CHAR(40),
> Provincia CHAR(2),
> CAP CHAR(5),
> Telefono CHAR(20),
> EMail CHAR(60),
> Login CHAR(20) NOT NULL,
> Password CHAR(20) NOT NULL,
> DataNascita DATE,
> LuogoNascita CHAR(40),
> Matricola CHAR(7) NOT NULL,
> AnnoImmatricolazione DATE,
> AnnoAccademico SET('1','2','3','4','5'),
> TipoAnno SET('C','F','R'),
> Corso CHAR(60),
> Orientamento CHAR(40),
> DataRegistrazione DATE NOT NULL,
> LastLogin DATE NOT NULL,
> LastDefault SET('F','N') DEFAULT 'N',
> Privilegi SET('R','P','A','S','C') NOT NULL DEFAULT 'S',
> Qualifica CHAR(20),
> Conoscenze TEXT,
> UNIQUE (Login)
> );
>
> CREATE TABLE progetti (
> IDProgetto INT(4) AUTO_INCREMENT PRIMARY KEY,
> MEsame CHAR(10) NOT NULL,
> MLavoro CHAR(10) NOT NULL,
> NomeProgetto CHAR(60) NOT NULL,
> Descrizione CHAR(255),
> URLDescrizione CHAR(100),
> Stato SET('T','N') NOT NULL DEFAULT 'N',
> ScadenzaPrevista DATE,
> Vincoli CHAR(255),
> Proposto SET('P','U') NOT NULL DEFAULT 'U',
> KEY (MEsame),
> KEY (Stato),
> KEY (Proposto),
> KEY (MLavoro)
> );
>
> $result = mysql_db_query( $database_connLiceo , "$SQL",$connLiceo );
> if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); }
> echo ("links Results RESULTS = $result\n\n");
> mysql_close($connLiceo);
> ?>


1 question the wisdom of telling us all your password
2 interesting that the database name is set up as a variable, but then
defined as a string-constant
3 MySQL will not accept multiple SQL statements in one call
4 when the $SQL variable is set, the value should be a string/enclosed in
double-quotes (ensure all SQL quotes are single-quotes/apostrophes)
5 personally I prefer to put all definitions into .SQL files and handle
within MySQL/Admin, rather than transactional code (but I don't know what
the rest of your script will do)
6 mysql_db_query has been deprecated. Recommend use of mysql_query()
7 within the query function, $SQL does not need to be enclosed within
double-quotes
8 always a good idea to check that things have worked as expected, eg
response from database select, contents of $SQL prior to query
9 not sure that you are going to get back what you expect from $result - the
above code will give you a resource label, nothing else.

Perhaps you should check out some of the introductory articles on the PHP
and MySQL combination, eg Kevin Yank's piece.

Regards,
=dn


-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to