chce się nauczyć obsługi baz danych znalazłem w domu książkę Helion "Od Podstaw PHP4" wydanie 2000r.

tam jest opis jak zainstalować bazę danych na swoim komputerze itp... ale ja mam bazę danych na dydku i raczej nie mogę obsługiwać tej bazy z pod wiersza poleceń ale w książce też jest napisane jak utworzyć tabele i bazę przez php. Już zrobiłem obsługę błędów połączyłem się z bazą... i chcę wrzucić tabele do bazy.. zrobiłem tak:
plik: create_db.php
<? include "./common_db.inc"; $dbname = "xxxxxxxxxxxxxxxxxxxxxxxxx"; $user_tablename = 'user'; $user_table_def = "usernumber MEDIUMINT(10) DEFAULT '0' NOT NULL AUTO_INCREMENT,"; $user_table_def .= "userid VARCHAR(8) BINARY NOT NULL,"; $user_table_def .= "userpassword VARCHAR(20) BINARY NOT NULL,"; $user_table_def .= "username VARCHAR(30) NOT NULL,"; $user_table_def .= "usercountry VARCHAR(50) NOT NULL,"; $user_table_def .= "useremail VARCHAR(50) NOT NULL,"; $user_table_def .= "userprofile TEXT NOT NULL,"; $user_table_def .= "registerdate DATE DEFAULT '0000-00-00' NOT NULL,"; $user_table_def .= "lastaccesstime TIMESTAMP(14),"; $user_table_def .= "PRIMARY KEY (userid),"; $user_table_def .= "UNIQUE usernumber (usernumber)"; $access_log_tablename = "access_log"; $access_log_table_def = "page VARCHAR(250) NOT NULL,"; $access_log_table_def .= "userid VARCHAR(8) BINARY NOT NULL,"; $access_log_table_def .= "visitcount MEDIUMINT(5) DEFAULT '0' NOT NULL,"; $access_log_table_def .= "accessdate TIMESTAMP(14),KEY page (page),"; $access_log_table_def .= "PRIMARY KEY (userid, page),"; $link_id = db_connect(); ?>
common_db.inc
<? $dbhost = 'localhost'; $dbusername = 'xxxxxxxxxxxxxx'; $dbuserpassword = 'xxxxxxxxxxxxxx'; $default_dbname = 'xxxxxxxxxxxxxx'; $MYSQL_ERRNO = ''; $MYSQL_ERROR = ''; function db_connect() { if(!$link_id) { $MYSQL_ERRNO = 0; $MYSQL_ERROR = "Nie udało się nawiązać połączenia z $dbhost."; return 0; } return 0; } else return $link_id; } function sql_error() { } return "$MYSQL_ERRNO: $MYSQL_ERROR"; } ?>
Oczywiście x to tam dane były ;p
gdy załaduję pliki na serwer i odpalę create_db.php mam komunikat:
1067: Niewła?ciwa warto?ć domy?lna dla 'usernumber'
wyrzuciłem AUTO_INCREMENT z
<?php $user_table_def = "usernumber MEDIUMINT(10) DEFAULT '0' NOT NULL AUTO_INCREMENT,"; ?>
i odpaliłem znowu plik create_db.php
to mam komunikat: 1064: Something is wrong in your syntax obok ')' w linii 1
Ale gdy wchodzę w phpmyadmin to mam tabele user a w niej

AUTO_INCREMENT dodałem do usernumber przez phpadmin ale nie wiem co błędem :
1064: Something is wrong in your syntax obok ')' w linii 1
Jestem zielony proszę o pomoc...