MCBR Corporation Posted March 18, 2006 at 02:28 AM Report #18647 Posted March 18, 2006 at 02:28 AM Como irei dizer isto ?... É assim, eu estou a criar um script e já resolvi muitos problemas que tinha com MySQL. Quando tiver mais alguma duvida voltarei a posta la aqui. /*Create MySQL tables*/ CREATE TABLE `content_basic` ( id INT NOT NULL AUTO_INCREMENT , sitetitle BLOB NOT NULL , sitedescription BLOB NOT NULL , sitekeywords BLOB NOT NULL , siteauthor BLOB NOT NULL , sitecopyright BLOB NOT NULL , logo BLOB NOT NULL , news BLOB NOT NULL , content1 BLOB NOT NULL , content2 BLOB NOT NULL , content3 BLOB NOT NULL , footernote BLOB NOT NULL , PRIMARY KEY ( id ) ); /*Insert data*/INSERT INTO `content_basic` ( `id` , `sitetitle` , `sitedescription` , `sitekeywords` , `siteauthor` , `sitecopyright` , `logo` , `news` , `content1` , `content2` , `content3` , `footnote` ) VALUES ( '', 'MCBR Scriptar Powered Website', 'MCBR Scriptar Powered Website - Using the next generation CMS.', 'mcbr, scriptar, website, php, official, website, mcbr, corporation, mysql, logo', 'MCBR Corporation', '© MCBR Corporation 2005-2006', 'http://www.mcbrhosting.com/scriptar/scriptarlogo.gif', 'MCBR Scriptar first launch! After so many days, MCBR Scriptar can now see the lights of the stage. This is version 0.06 and we are glad to say that we will not stop developing it.', 'MCBR Scriptar Hosting - We will soon be selling MCBR Scriptar Hosting! 6.5$ per year if you have a domain, 13$ if you don''t.', 'MCBR Scriptar has lots of good features. If you are seeing this message, then you successfully installed it in your server.', 'Content in content box 3. Content in content box 3.Content in content box 3. Content in content box 3.Content in content box 3. Content in content box 3.Content in content box 3. Content in content box 3.', ' ©MCBR Corporation 2005-2006' ); Está tudo correcto?
deathseeker25 Posted March 18, 2006 at 12:32 PM Report #18664 Posted March 18, 2006 at 12:32 PM Bem, devias ter colocado esta duvida directamente na secção SQL, que é que vou fazer de seguida. Em primeiro lugar, aconselho-te a dares uma leitura neste site: http://www.w3schools.com/sql/default.asp. Numa horinha ficas a conhecer os comandos básicos de SQL que podes utilizar em MySQL. Mas essa tabela é fácil de preencher: CREATE TABLE `content_basic` ( id INT not null AUTO_INCREMENT, sitetitle VARCHAR(50), sitedescription VARCHAR(50), sitekeywords VARCHAR(30), siteauthor VARCHAR(40), sitecopyright VARCHAR(30), logo VARCHAR(60), news VARCHAR(300), content1 VARCHAR(50), content2 VARCHAR(50), content3 VARCHAR(50), footnote VARCHAR(20) ) TYPE = MYISAM É basicamente isto. Não sei ao certo o que queres que os campos leiam, mas podes sempre modificar quando souberes mais de SQL.
MCBR Corporation Posted March 18, 2006 at 12:45 PM Author Report #18666 Posted March 18, 2006 at 12:45 PM Os campos podem sempre ler isto. Obrigado pela ajuda. varcher(300) signifca k pode ter 300 caracteres, certo?
deathseeker25 Posted March 18, 2006 at 12:46 PM Report #18667 Posted March 18, 2006 at 12:46 PM Os campos podem sempre ler isto. Obrigado pela ajuda. varcher(300) signifca k pode ter 300 caracteres, certo? Exacto. Se leres o tutorial que te forneci vais ficar a saber que existem outros métodos para armazenar caracteres que não utilizando o VARCHAR, métodos esses muito úteis para armazenar um número enorme de caracteres. 🙂
MCBR Corporation Posted March 18, 2006 at 12:56 PM Author Report #18668 Posted March 18, 2006 at 12:56 PM Os varchar só dao para 255 caracteres :\ Deu me um erro: Documentação #1075 - Incorrect table definition; There can only be one auto column and it must be defined as a key
deathseeker25 Posted March 18, 2006 at 02:04 PM Report #18677 Posted March 18, 2006 at 02:04 PM Os varchar só dao para 255 caracteres :\ Deu me um erro: Documentação #1075 - Incorrect table definition; There can only be one auto column and it must be defined as a key Esqueci-me desse pormenor dos 255 caracteres máximos... Quanto ao erro, só podes criar um campo por tabela que tenha AUTO_INCREMENT, e geralmente esse campo é considerado chave-primária na tabela: CREATE TABLE `content_basic` ( id INT NOT NULL AUTO_INCREMENT, sitetitle VARCHAR(50), sitedescription VARCHAR(50), sitekeywords VARCHAR(30), siteauthor VARCHAR(40), sitecopyright VARCHAR(30), logo VARCHAR(60), news VARCHAR(255), content1 VARCHAR(50), content2 VARCHAR(50), content3 VARCHAR(50), footnote VARCHAR(20) PRIMARY KEY (id) ) Assim já deve funcionar.... 🙂
MCBR Corporation Posted March 18, 2006 at 02:30 PM Author Report #18678 Posted March 18, 2006 at 02:30 PM Funcionou. Já agora, mais uma coisa. Como é que eu faço com que quando vai a criar a tabela também crie um registo lá?
pebat Posted March 18, 2006 at 02:31 PM Report #18679 Posted March 18, 2006 at 02:31 PM fazes assim create table campos; insert into tabela (campos) values (dados);
MCBR Corporation Posted March 18, 2006 at 02:35 PM Author Report #18680 Posted March 18, 2006 at 02:35 PM INSERT campos () - dentro de parenteses escolho o campo em que devo meter a cena? values (blablabla)...
pedrotuga Posted March 18, 2006 at 09:41 PM Report #18719 Posted March 18, 2006 at 09:41 PM Google:mysql manual insert devolveu no primeiro resultado isto: http://dev.mysql.com/doc/refman/5.0/en/insert.html Mais facil que isto é impossivel... há três possibilidades na sintaxe do insert. Eu uso quase sepre a segunda opcao. Ora ve la no link acima.... é facil 🙂
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now