php met sql table maken

Status
Niet open voor verdere reacties.

trical

Gebruiker
Lid geworden
17 mrt 2007
Berichten
40
PHP:
<?
$user="timder12_game";
$password="xxx";
$database="timder12_game";
$localhost="mysql4.freehostia.com";
mysql_connect($localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
$setup="CREATE TABLE user (id int(6) NOT NULL auto_increment,username varchar(15) NOT NULL,password varchar(15) NOT NULL,email varchar(30) NOT NULL)";
mysql_query($setup);
print("table created");
mysql_close();
?>

deze pagina heet index.php en als ik naar mijn site ga komt er gewoon table created maar als ik in phpadmin kijk is er geen table...
 
Zet eens achter die mysql_query($setup) or die (mysql_error());

Foutje in je query waarschijnlijk.

Die print komt sowieso dus of de tabel nou aangemaakt is of niet..
 
Incorrect table definition; there can be only one auto column and it must be defined as a key

dus de auto kolom moet de primaire sleutel zijn, hoe doe je dat in php/sql ??:)
 
Wijzig deze query:
PHP:
$setup="CREATE TABLE user (id int(6) NOT NULL auto_increment,username varchar(15) NOT NULL,password varchar(15) NOT NULL,email varchar(30) NOT NULL)";
In:
PHP:
$setup="CREATE TABLE user (id int(6) NOT NULL primary key auto_increment,username varchar(15) NOT NULL,password varchar(15) NOT NULL,email varchar(30) NOT NULL)";
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan