Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [SQL][MYSQL]Dobrze robie ?, prosze o sprawdzenie
kjiu
post
Post #1





Grupa: Zarejestrowani
Postów: 34
Pomógł: 0
Dołączył: 20.02.2009

Ostrzeżenie: (0%)
-----


Witam..

Troche glupia prozba ale czy dobrze to napisalem ?

Cytat
CREATE TABLE `users` (
`user_id` int(8) NOT NULL auto_increment,
`user_nick` varchar(20) NOT NULL default '',
`user_login` varchar(20) NOT NULL default '',
`user_password` varchar(30) NOT NULL default '',
`user_emial` varchar(40) NOT NULL default '',
`user_birthdate` DATETIME NOT NULL default '',
`user_live` varchar(30) NOT NULL default '',
`user_like` varchar(25) NOT NULL default '',
KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

INSERT
INTO `uzytkownicy` VALUES (1, 'admin', 'admin', 'db42fd', 'kevinek0@wp.pl', ' ', 'Tarnów', 'Php');


Chodzi mi oto zebym pozniej problemow nie mial dry.gif

Ten post edytował kjiu 22.04.2009, 13:46:08
Go to the top of the page
+Quote Post
wookieb
post
Post #2





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




W czym problemów?

"user_emial" znajdz literówke

@UP Kolega niżej wkleił zrobił coś niesamowicie trudnego ZA ciebie. Wykonał to zapytanie o.0! Ty nie potrafisz?

Ten post edytował wookieb 22.04.2009, 13:51:52


--------------------
Go to the top of the page
+Quote Post
mszm
post
Post #3





Grupa: Zarejestrowani
Postów: 10
Pomógł: 1
Dołączył: 22.04.2009

Ostrzeżenie: (0%)
-----


Cytat
MySQL zwrócił komunikat:

#1072 - Key column 'id' doesn't exist in table
Go to the top of the page
+Quote Post
_olo_1984
post
Post #4





Grupa: Zarejestrowani
Postów: 289
Pomógł: 77
Dołączył: 5.08.2006

Ostrzeżenie: (0%)
-----


bo kluczem ma być user_id a nie id, popraw linijke "KEY `id` (`id`)"


--------------------
awake
Go to the top of the page
+Quote Post
kjiu
post
Post #5





Grupa: Zarejestrowani
Postów: 34
Pomógł: 0
Dołączył: 20.02.2009

Ostrzeżenie: (0%)
-----


ok dzieki .. a czy
Cytat
`user_birthdate` DATETIME NOT NULL default '',

dobrze zrobilem ?

Ten post edytował kjiu 22.04.2009, 13:57:33
Go to the top of the page
+Quote Post
phpion
post
Post #6





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




Jeśli chcesz trzymać datę oraz CZAS narodzin to dobrze. Dla samej daty wystarczy typ DATE. No i wartość domyślna jest zbędna.
Go to the top of the page
+Quote Post
kjiu
post
Post #7





Grupa: Zarejestrowani
Postów: 34
Pomógł: 0
Dołączył: 20.02.2009

Ostrzeżenie: (0%)
-----


mam jeszcze pytanie.. zrobilem tak :
Cytat
C:\usr\mysql\bin>mysql -h localhost -u root -p krasnal
Enter password: *******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14 to server version: 3.23.58-max-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database portal;
Query OK, 1 row affected (0.00 sec)

mysql> use portal;
Database changed
mysql>
mysql> CREATE TABLE `users` (
-> `user_id` int(8) NOT NULL auto_increment,
-> `user_nick` varchar(20) NOT NULL default '',
-> `user_login` varchar(20) NOT NULL default '',
-> `user_password` varchar(30) NOT NULL default '',
-> `user_emial` varchar(40) NOT NULL default '',
-> `user_birthdate` DATETIME NOT NULL default '',
-> `user_live` varchar(30) NOT NULL default '',
-> `user_like` varchar(25) NOT NULL default '',
-> KEY `user_id` (`user_id`)
-> ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
ERROR 1064: Something is wrong in your syntax obok 'ENGINE=MyISAM DEFAULT CHARSE
T=latin1 AUTO_INCREMENT=2' w linii 11
mysql>
mysql>
mysql>
mysql> INSERT
-> INTO `users` VALUES (1, 'admin', 'admin', 'db42fd', 'kevinek0@wp.pl', ' '
, 'Tarnów', 'Php');
ERROR 1146: Table 'portal.users' doesn't exist


prosze o pomoc
Go to the top of the page
+Quote Post
Spawnm
post
Post #8





Grupa: Moderatorzy
Postów: 4 069
Pomógł: 497
Dołączył: 11.05.2007
Skąd: Warszawa




nie słyszałem o ENGINE , daj TYPE=MyISAM
Go to the top of the page
+Quote Post
phpion
post
Post #9





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




Cytat(Spawnm @ 22.04.2009, 16:40:00 ) *
nie słyszałem o ENGINE

http://dev.mysql.com/doc/refman/5.1/en/create-table.html
Cytat
The older TYPE option was synonymous with ENGINE. TYPE has been deprecated since MySQL 4.0 but is still supported for backward compatibility in MySQL 5.1 (excepting MySQL 5.1.7). Since MySQL 5.1.8, it produces a warning. It is removed as of MySQL 5.2. You should not use TYPE in any new applications, and you should immediately begin conversion of existing applications to use ENGINE instead.

Możliwe, że autor używa star(sz)ej wersji MySQL i zmiana ENGINE -> TYPE pomoże.
Go to the top of the page
+Quote Post
kjiu
post
Post #10





Grupa: Zarejestrowani
Postów: 34
Pomógł: 0
Dołączył: 20.02.2009

Ostrzeżenie: (0%)
-----


Cytat
C:\usr\mysql\bin>mysql -h localhost -u root -p krasnal
Enter password: *******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19 to server version: 3.23.58-max-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database portal;
ERROR 1007: Nie mo┐na stworzyŠ bazy danych 'portal'. Baza danych ju┐ istnieje
mysql> drop database portal;
Query OK, 0 rows affected (0.00 sec)

mysql> create database portal;
Query OK, 1 row affected (0.00 sec)

mysql> use portal;
Database changed
mysql> CREATE TABLE `users` (
-> `user_id` int(8) NOT NULL auto_increment,
-> `user_nick` varchar(20) NOT NULL default '',
-> `user_login` varchar(20) NOT NULL default '',
-> `user_password` varchar(30) NOT NULL default '',
-> `user_emial` varchar(40) NOT NULL default '',
-> `user_birthdate` DATETIME NOT NULL default '',
-> `user_live` varchar(30) NOT NULL default '',
-> `user_like` varchar(25) NOT NULL default '',
-> KEY `user_id` (`user_id`)
-> ) TYPE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
ERROR 1064: Something is wrong in your syntax obok 'DEFAULT CHARSET=latin1 AUTO_
INCREMENT=2' w linii 11
mysql>
mysql>
mysql>
mysql> INSERT
-> INTO `users` VALUES (1, 'admin', 'admin', 'db42fd', 'kevinek0@wp.pl', ' '
, 'Tarnów', 'Php');
ERROR 1146: Table 'portal.users' doesn't exist
mysql>
mysql>


sadsmiley02.gif sadsmiley02.gif

prosze o odpowiedz

pomoze ktos questionmark.gif
Go to the top of the page
+Quote Post
phpion
post
Post #11





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




Teraz zwróciłem uwagę jaką prehistoryczną wersję MySQL posiadasz. Spróbuj więc wywalić z zapytania tworzącego tabelę:
Kod
ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2

czyli żeby ostatnia linijka wyglądała po prostu tak:
Kod
);

Teraz już powinno pójść...
Go to the top of the page
+Quote Post
kjiu
post
Post #12





Grupa: Zarejestrowani
Postów: 34
Pomógł: 0
Dołączył: 20.02.2009

Ostrzeżenie: (0%)
-----


oki dziala.. teraz trzeba index.php czarodziej.gif
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 22:07