Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

guto_onidesk

Problem with txt file

Recommended Posts

hello people there http://forum.imasters.com.br/public/style_emoticons/default/joia.gif

i´m building a script to my faq section on the web site.

to prevent from malicious users when posting something i want the users post the article on a textarea and code in other textarea (article goes to database and source code goes to txt file).

So, this first part is working well.

The text posted on textarea code goes to the txt and the other goes to database.

 

The problem peep up when i want to read it from file.

Here are my three problems

 

1º - to read and print the code on the txt, it will won´t split the code if he had the tags <?php ?>

or other due the config on the php.ini

 

I want split the code without change the configurations on php.ini

testing it without the tags , the source is splited ok

 

2º when i post a new thread , the first posting on the txt file is erased. the code desappear

The article on database is ok

 

3º How can i associate an certain code on the txt to the correspondent article on database

 

you can see what i want on

 

 

Onidesk

 

Regards http://forum.imasters.com.br/public/style_emoticons/default/thumbsup.gif

Guto Ferreira

Compartilhar este post


Link para o post
Compartilhar em outros sites

hi guys http://forum.imasters.com.br/public/style_emoticons/default/thumbsup.gif

 

i am the poster of this topic

 

When in am posting i insert on the txt file the id correspondent on database to the article through the function mysql_insert_id, and it works ok

 

The txt has now a id to each article sended to database

 

How can i associate the id on txt to the id on database and split out contents at the same time .

 

I still having a problem, each time i write a new article the contents on txt are erased, and changed by the most recent.

 

I know i had to create a pointer to the end of the text writed.

 

Making this to the next time i write a new one the txt will be filled in at the end of the article above.

 

How can i do that ???? http://forum.imasters.com.br/public/style_emoticons/default/blush.gif

 

you can check what on

Onidesk

 

I need some help

 

Regards

Guto Ferreira from Portugal

Compartilhar este post


Link para o post
Compartilhar em outros sites

lol se voçe é de portugal ( como eu ) porque voçe não postou em portugues?

Compartilhar este post


Link para o post
Compartilhar em outros sites

A RAZÃO DE EU ENVIAR O TOPICO EM INGÊS É QUE ESTIVE A POR ESTA MENSAGEM NUM SITE INGLÊS NÃO QUERO FERIR SUSCEPTIBILIDADES, EU POSSO TRADUZIR A MENSAGEM PARA QUEM NÃO PERCEBER

DESCULPEM , MAS FOI PERGUIÇA ;)

 

o assunto é o seguinte:

 

Estou a construir um script no qual quero separar o código fonte ( todo o código restringido pelas tags ... <?php ?> , <% %>)

do resto do artigo.Para fazer isso criei duas area de texto

 

assim:

<p>Artigo:<br><textarea name=\"codigo\" rows=\"6\" cols=\"40\"></textarea></p>

<p>Código:<br><textarea name=\"codigo\" rows=\"6\" cols=\"40\"></textarea></p>

 

a primeira envia o código para o banco de dados e a segundaenvia o código fonte para um ficheiro txt

 

 

Até aquí tudo bem http://forum.imasters.com.br/public/style_emoticons/default/thumbsup.gif .

 

 

Eu enviei para o ficheiro txt o id corespondente ao artigo na base de dados.

 

Agora noutra página eu quero imprimir o artigo da base de dados e o código do txt juntamente

 

para isso estou a tentar utilizar o seguinte código

 

mas não está a responder aquilo que eu quero

 

$fd = @fopen( "noticias/artigos.txt", "r" ) ; // abrimos o ficheiro em mode de leitura apenas

fseek($fd,0,SEEK_SET); // colocamos o ponteiro ao inicio na posição zero

while( !feof( $fd ) ) { // varremos o ficheiro até ao final

$str = fread($fd,1024);

echo"<input type='hidden' value='".$str."'>"; // pesquisamos no ficheiro o id correspondente na base de dados e imprimimos como string hidden

$pesquisa = mysql_query("SELECT * id FROM faq where id like '%".$str."%' "); // fazemos a consulta na tabela

}

 

if($pesquisa==true){ // se o id da consulta for igual ao encontrado no txt imprimimos o artigo

print $str;

}else{

fclose($fd); // senão fechamos o arquivo

}

}

 

 

 

http://forum.imasters.com.br/public/style_emoticons/default/blush.gif Preciso de ajuda

Desde já obrigado pela apoio

 

Webmaster Guto Ferreira

http://forum.imasters.com.br/public/style_emoticons/default/joia.gif

Compartilhar este post


Link para o post
Compartilhar em outros sites

Isso: SELECT * id FROM faq where id like '%".$str."%'Não deveria ser isso: SELECT * FROM faq WHERE id LIKE '%".$str."%' ?

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.