xhpotterx Posted April 11, 2013 at 09:07 AM Report #502693 Posted April 11, 2013 at 09:07 AM Boas pessoal tenho uma query onde faz a criação de uma tabela com as colunas. $query = "CREATE TABLE ['$ProjPais'] (IdLang int NOT NULL AUTO_INCREMENT ,Lang CHAR(30),Pais CHAR(30),PRIMARY KEY (IdLang));"; mysql_query($query) or die('Query "' . $query . '" failed: ' . mysql_error()); header('Location:content.php'); Mas quando a variavel guarda um valor tipo pt-PT não cria a tabela e mostra me a query no form Cumpz
joaocasta Posted April 11, 2013 at 09:22 AM Report #502697 Posted April 11, 2013 at 09:22 AM (edited) Boas. 1º identa o codigo. [ CODE = PHP] code code code [/code] Tenta assim: $query = mysql_query("CREATE TABLE `$ProjPais`( IdLang INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(IdLang), Lang CHAR(30), Pais CHAR(30))") or die('Query "' . $query . '" failed: ' . mysql_error()); header("Location: content.php"); Vê se isto te ajuda. Cumps. Edited April 11, 2013 at 09:23 AM by joaocasta 1 Report
xhpotterx Posted April 11, 2013 at 09:38 AM Author Report #502702 Posted April 11, 2013 at 09:38 AM Joaocasta o seu código funciona de verdade Valeu Cumps
xhpotterx Posted April 11, 2013 at 11:21 AM Author Report #502753 Posted April 11, 2013 at 11:21 AM O código de criar a tabela e isso ja esta mas a query de apagar uma tabela ainda me esta a dar erro por causa do - . $query = mysql_query('DROP TABLE IF EXISTS `projetos`.`$ProjPais`') or die(mysql_error());
pikax Posted April 11, 2013 at 11:32 AM Report #502757 Posted April 11, 2013 at 11:32 AM Usem a estencao do mysqli*, e' mais segura do que o mysql* que ja' esta' desactualizado e fora de desenvolvimento... Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."
joaocasta Posted April 11, 2013 at 12:34 PM Report #502775 Posted April 11, 2013 at 12:34 PM Sim é verdade pikax. Eu agora estou a usar PDO, mas como ela estava a usar mysql deixei estar. projetos é a base de dados? faz assim: $query = mysql_query('DROP TABLE IF EXISTS $ProjPais') or die(mysql_error());
xhpotterx Posted April 11, 2013 at 12:38 PM Author Report #502776 Posted April 11, 2013 at 12:38 PM JoaoCasta obrigadão ja esta a funcionar ja so me falta fazer o update para o botao editar e fica pronto.
xhpotterx Posted April 11, 2013 at 01:00 PM Author Report #502779 Posted April 11, 2013 at 01:00 PM Tipo num botão editar tenho que lhe fazer o update , mas como fasso o update se tipo alterar todo o texto dos campos da tabela?
joaocasta Posted April 11, 2013 at 01:02 PM Report #502780 Posted April 11, 2013 at 01:02 PM Não te percebi. Estás a dizer que queres fazer update a tudo ou só a certos campos?
xhpotterx Posted April 11, 2013 at 01:09 PM Author Report #502783 Posted April 11, 2013 at 01:09 PM Tipo a tabela tem 5 campos e eu quero fazer o update a 4 campos mas esse unico campo que nao leva update e o id mas que não e mostrado nor form. Como fasso?
pikax Posted April 11, 2013 at 01:14 PM Report #502787 Posted April 11, 2013 at 01:14 PM e' um update normal.... UPDATE login SET username = '$name', passw = '$sPass' WHERE id = $id Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."
xhpotterx Posted April 11, 2013 at 01:19 PM Author Report #502789 Posted April 11, 2013 at 01:19 PM (edited) Aparece este erro: Query "UPDATE tbLang SET Lang=Portu, Pais=Port, SiglaLang=pt-PTT;" failed: Unknown column 'Portu' in 'field list' Minha Query: $id=$_POST['id']; $query = mysql_query("UPDATE tbLang SET Lang = '$Lang', SiglaLang = '$SiglaLang', Pais='$Pais' WHERE id = $id") or die(mysql_error()); Edited April 11, 2013 at 01:22 PM by xhpotterx
pikax Posted April 11, 2013 at 01:25 PM Report #502792 Posted April 11, 2013 at 01:25 PM o erro que te esta' a dar e' devido o sql pensar que o Portu e' um campo da coluna em vez de uma string, para isso falta-te as plicas('). O erro que da' e' da query que postaste? Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."
HappyHippyHippo Posted April 11, 2013 at 01:25 PM Report #502794 Posted April 11, 2013 at 01:25 PM tenho sérias dúvidas que o SQL criado com o PHP amostrado resulta numa mensagem de erro dessas ... testa novamente (lembra-te de gravar o ficheiro) e diz alguma coisa IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
xhpotterx Posted April 11, 2013 at 01:31 PM Author Report #502796 Posted April 11, 2013 at 01:31 PM Esse erro foi o que me apareceu na web depois de eu submeter o editar
pikax Posted April 11, 2013 at 01:36 PM Report #502801 Posted April 11, 2013 at 01:36 PM porque que nao comecas a ganhar umas boas praticas de seguranca, entre outros. E comecas a usar o mysqli*, com os Prepared statement Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."
xhpotterx Posted April 12, 2013 at 10:40 AM Author Report #502926 Posted April 12, 2013 at 10:40 AM (edited) Topico Resolvido. Não me aparece o botão de marca como resolvido :0 Edited April 12, 2013 at 10:40 AM by xhpotterx
pikax Posted April 12, 2013 at 10:48 AM Report #502930 Posted April 12, 2013 at 10:48 AM (edited) podes submeter a tua solucao, para caso alguem futuramente tenha uma duvida parecida com a tua, ficar mais esclarecido. Edited April 12, 2013 at 10:48 AM by pikax Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."
xhpotterx Posted April 12, 2013 at 01:34 PM Author Report #502960 Posted April 12, 2013 at 01:34 PM A solução é a do João Casta. $query = mysql_query("CREATE TABLE `$ProjPais`( IdLang INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(IdLang), Lang CHAR(30), Pais CHAR(30))") or die('Query "' . $query . '" failed: ' . mysql_error()); header("Location: content.php");
HappyHippyHippo Posted April 12, 2013 at 03:50 PM Report #502983 Posted April 12, 2013 at 03:50 PM dizes que tens este erro: Aparece este erro: Query "UPDATE tbLang SET Lang=Portu, Pais=Port, SiglaLang=pt-PTT;" failed: Unknown column 'Portu' in 'field list' Minha Query: $id=$_POST['id']; $query = mysql_query("UPDATE tbLang SET Lang = '$Lang', SiglaLang = '$SiglaLang', Pais='$Pais' WHERE id = $id") or die(mysql_error()); depois dizes que a solução é um SQL que não tem nada haver ??? A solução é a do João Casta. $query = mysql_query("CREATE TABLE `$ProjPais`( IdLang INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(IdLang), Lang CHAR(30), Pais CHAR(30))") or die('Query "' . $query . '" failed: ' . mysql_error()); header("Location: content.php"); não admira que estivesse complicado ... IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
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