AKB Forums

Go Back   AKB Forums > Technical sections > Languages, Compilers and Interpreters > Web Development
Home Register Blogs FAQ Members List Calendar Downloads Arcade Mark Forums Read

Web Development Java/PHP/Perl/ASP and more

Troubles when posting message? Click here! :: Проблемы с отправлением сообщения? Нажмите сюда!

Reply
 
LinkBack Thread Tools Display Modes
Old Jan 11, 2007, 13:56   #1
I Love BMW!
 
ExtremeSM's Avatar
 
Join Date: Nov 2006
Location: reload();
Posts: 63
Rep Power: 0
Reputation: 10
Wink PHP / Need Help / Search in file

Всем здорово, помогите с ПХП, плиз, я новичок в этой сфере, как найти в файле "data.txt" допустим, стринг "$user" например, а потом его удалить из этого файла нафиг, но чтобы остальной контент файла остался... Плиз, приведите пример, мастера ПХП

Надеюсь на помощь, заранее благодарен...
__________________
http://megauploader.net/ ------ new designed, new engine powered now still free, fast and without registration...
ExtremeSM is offline   Reply With Quote Quote selected
Old Jan 12, 2007, 01:04   #2
йес эм эли...
 
Mesrop's Avatar
 
Join Date: Feb 2005
Location: near the computer
Posts: 3,183
Rep Power: 4
Reputation: 61
Send a message via ICQ to Mesrop Send a message via AIM to Mesrop Send a message via MSN to Mesrop Send a message via Yahoo to Mesrop Send a message via Skype™ to Mesrop
PHP Code:
<?
$filenm
="data.txt";
$source=file($filenm);
$string='user';
foreach (
$source as $line_num => $line) {
if(
strpos($line,$string)==TRUE){
$myline=$line_num;
    }
}
if (
$myline==true){

    
$fp=fopen($filenm,"w");
    for(
$i=0;$i<sizeof($source);$i++)
        {
        if(
$i==$myline)
        {unset(
$source[$i]);}
        }
if(
fputs($fp,implode("",$source))==TRUE){echo "Done";}
fclose($fp); }
?>
если у тебя
в data.txt типа (амен тохи вра 1 стринг)
Quote:
$1111=".....
$user="myname";
$aaa=".....
$bbb=".....
Mesrop is offline   Reply With Quote Quote selected
Old Jan 12, 2007, 11:44   #3
I Love BMW!
 
ExtremeSM's Avatar
 
Join Date: Nov 2006
Location: reload();
Posts: 63
Rep Power: 0
Reputation: 10
Quote:
Originally Posted by Mesrop View Post
PHP Code:
<?
$filenm
="data.txt";
$source=file($filenm);
$string='user';
foreach (
$source as $line_num => $line) {
if(
strpos($line,$string)==TRUE){
$myline=$line_num;
    }
}
if (
$myline==true){
 
    
$fp=fopen($filenm,"w");
    for(
$i=0;$i<sizeof($source);$i++)
        {
        if(
$i==$myline)
        {unset(
$source[$i]);}
        }
if(
fputs($fp,implode("",$source))==TRUE){echo "Done";}
fclose($fp); }
?>
если у тебя
в data.txt типа (амен тохи вра 1 стринг)
Думаю ты меня не правильно понял, у меня на каждой строчке в дата.тхт ->

PHP Code:
word1
word2
word3
word4
word5 
просто слова, надо, чтобы просто серч типа делался...
Вообщем у меня уже получилось чегото вроде того, что мне нада
теперь тока одна проблема, у меня есть страница, которая выводит из этого самого файла дата.тхт текст весь, тоесть просто fread(); тока она у меня все время остается прежней, сколько бы я ее не рефрешал, тоесть у меня no-cache не работает
плиз помоги, я прямо из пхп справочника копировал, 4 строки для "ноу кеш"-а...
__________________
http://megauploader.net/ ------ new designed, new engine powered now still free, fast and without registration...
ExtremeSM is offline   Reply With Quote Quote selected
Old Jan 12, 2007, 12:32   #4
йес эм эли...
 
Mesrop's Avatar
 
Join Date: Feb 2005
Location: near the computer
Posts: 3,183
Rep Power: 4
Reputation: 61
Send a message via ICQ to Mesrop Send a message via AIM to Mesrop Send a message via MSN to Mesrop Send a message via Yahoo to Mesrop Send a message via Skype™ to Mesrop
Quote:
Originally Posted by ExtremeSM View Post
Думаю ты меня не правильно понял, у меня на каждой строчке в дата.тхт ->
просто слова, надо, чтобы просто серч типа делался...
Вообщем у меня уже получилось чегото вроде того, что мне нада
теперь тока одна проблема, у меня есть страница, которая выводит из этого самого файла дата.тхт текст весь, тоесть просто fread(); тока она у меня все время остается прежней, сколько бы я ее не рефрешал, тоесть у меня no-cache не работает
плиз помоги, я прямо из пхп справочника копировал, 4 строки для "ноу кеш"-а...
де ха им твац $string='user'; -и техе ко стринге днес, кашхти
код ф студио! с fread'ами и ноу-кеш'ами
Mesrop is offline   Reply With Quote Quote selected
Old Jan 12, 2007, 16:07   #5
I Love BMW!
 
ExtremeSM's Avatar
 
Join Date: Nov 2006
Location: reload();
Posts: 63
Rep Power: 0
Reputation: 10
Quote:
Originally Posted by Mesrop View Post
де ха им твац $string='user'; -и техе ко стринге днес, кашхти
код ф студио! с fread'ами и ноу-кеш'ами
чего-чего? не понял какой ф студио? что это такое?
__________________
http://megauploader.net/ ------ new designed, new engine powered now still free, fast and without registration...
ExtremeSM is offline   Reply With Quote Quote selected
Old Jan 12, 2007, 19:30   #6
йес эм эли...
 
Mesrop's Avatar
 
Join Date: Feb 2005
Location: near the computer
Posts: 3,183
Rep Power: 4
Reputation: 61
Send a message via ICQ to Mesrop Send a message via AIM to Mesrop Send a message via MSN to Mesrop Send a message via Yahoo to Mesrop Send a message via Skype™ to Mesrop
Quote:
Originally Posted by ExtremeSM View Post
чего-чего? не понял какой ф студио? что это такое?
хм... кузем ысел ор коде тур найенк
Mesrop is offline   Reply With Quote Quote selected
Old Jan 12, 2007, 21:33   #7
I Love BMW!
 
ExtremeSM's Avatar
 
Join Date: Nov 2006
Location: reload();
Posts: 63
Rep Power: 0
Reputation: 10
а ок Месроп джан, вот код:

PHP Code:
<?php
Header
("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); //Äàòà â ïðîøëîì
Header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
Header("Pragma: no-cache"); // HTTP/1.1
Header("Last-Modified: ".gmdate("D, d M Y H:i:s")."GMT");
?>

<body bgcolor="#cfcfcf">
<center>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="150" id="AutoNumber1" height="34">
<tr>
<td width="150" height="19">
<p align="center"><b><font color="#6699ff">Online Users</font></b></td>
</tr>
<tr>
<td width="150" height="14">
<p align="center">

<?php
$filename 
"data/online.db";
$handle fopen ($filename"r");
$contents fread ($handlefilesize ($filename));
print 
"$contents\r\n";
fclose ($handle);
?>


</td>
</tr>
</table>
__________________
http://megauploader.net/ ------ new designed, new engine powered now still free, fast and without registration...
ExtremeSM is offline   Reply With Quote Quote selected
Old Jan 13, 2007, 08:52   #8
йес эм эли...
 
Mesrop's Avatar
 
Join Date: Feb 2005
Location: near the computer
Posts: 3,183
Rep Power: 4
Reputation: 61
Send a message via ICQ to Mesrop Send a message via AIM to Mesrop Send a message via MSN to Mesrop Send a message via Yahoo to Mesrop Send a message via Skype™ to Mesrop
Header-neri mase sax karan hanesnax
im mot normal refreshi vaxt poxvum e, ete dzerov online.db -i mej grum em u save em anum.
kam apache'icd a, kam fwrite anox scriptic.
fwrite ф студио!
Mesrop is offline   Reply With Quote Quote selected
Old Jan 13, 2007, 09:15   #9
I Love BMW!
 
ExtremeSM's Avatar
 
Join Date: Nov 2006
Location: reload();
Posts: 63
Rep Power: 0
Reputation: 10
оки, а вот фврайт байц индз твума апачица, ми кани ангам ела тенц ехел:

PHP Code:
<?php
if($nick != '') {
$fk fopen("data/online.db""a");
fwrite($fk"$nick_log<br>");
fclose($fk);
}
if(
$nick != '' && $text != '') {
$fp fopen("data/msg.txt""a");
fwrite($fp"<u>$nick</u>: $text<br>");
fclose($fp);
}

?>
Isk karoxa vabshe kompicsa? LOL
__________________
http://megauploader.net/ ------ new designed, new engine powered now still free, fast and without registration...
ExtremeSM is offline   Reply With Quote Quote selected
Old Jan 13, 2007, 09:33   #10
Авик
 
CyberJoe's Avatar
 
Join Date: Jul 2002
Location: Yerevan
Posts: 1,347
Rep Power: 7
Reputation: 19
Send a message via ICQ to CyberJoe
ExtreemSM, зачем пишешь в файлы, а не в базу?
__________________
вот собственно все, что я хотел сказать.
CyberJoe is offline   Reply With Quote Quote selected
Old Jan 13, 2007, 09:38   #11
I Love BMW!
 
ExtremeSM's Avatar
 
Join Date: Nov 2006
Location: reload();
Posts: 63
Rep Power: 0
Reputation: 10
Quote:
Originally Posted by CyberJoe View Post
ExtreemSM, зачем пишешь в файлы, а не в базу?
хороший вопросик
не умею
__________________
http://megauploader.net/ ------ new designed, new engine powered now still free, fast and without registration...
ExtremeSM is offline   Reply With Quote Quote selected
Old Jan 13, 2007, 09:39   #12
I Love BMW!
 
ExtremeSM's Avatar
 
Join Date: Nov 2006
Location: reload();
Posts: 63
Rep Power: 0
Reputation: 10
Quote:
Originally Posted by Mesrop View Post
Header-neri mase sax karan hanesnax
im mot normal refreshi vaxt poxvum e, ete dzerov online.db -i mej grum em u save em anum.
kam apache'icd a, kam fwrite anox scriptic.
fwrite ф студио!
Кстати, а может это от фреймов??? у меня все это дело в фреймах лежит, может от этого кешуется?
__________________
http://megauploader.net/ ------ new designed, new engine powered now still free, fast and without registration...
ExtremeSM is offline   Reply With Quote Quote selected
Old Jan 13, 2007, 09:49   #13
йес эм эли...
 
Mesrop's Avatar
 
Join Date: Feb 2005
Location: near the computer
Posts: 3,183
Rep Power: 4
Reputation: 61
Send a message via ICQ to Mesrop Send a message via AIM to Mesrop Send a message via MSN to Mesrop Send a message via Yahoo to Mesrop Send a message via Skype™ to Mesrop
Quote:
Originally Posted by ExtremeSM View Post
Кстати, а может это от фреймов??? у меня все это дело в фреймах лежит, может от этого кешуется?
lav mitq ka. porci ed eje vochte frame-i mejic, ayl uxix url-ov kanchel...
Mesrop is offline   Reply With Quote Quote selected
Old Jan 14, 2007, 12:26   #14
I Love BMW!
 
ExtremeSM's Avatar
 
Join Date: Nov 2006
Location: reload();
Posts: 63
Rep Power: 0
Reputation: 10
Porcelem chi stacvum, baic achkis serveric a kam kompics =\
Ham el kak raz indz petqa frame-ic kanchel
__________________
http://megauploader.net/ ------ new designed, new engine powered now still free, fast and without registration...
ExtremeSM is offline   Reply With Quote Quote selected
Old Jan 14, 2007, 14:03   #15
йес эм эли...
 
Mesrop's Avatar
 
Join Date: Feb 2005
Location: near the computer
Posts: 3,183
Rep Power: 4
Reputation: 61
Send a message via ICQ to Mesrop Send a message via AIM to Mesrop Send a message via MSN to Mesrop Send a message via Yahoo to Mesrop Send a message via Skype™ to Mesrop
Quote:
Originally Posted by ExtremeSM View Post
Porcelem chi stacvum, baic achkis serveric a kam kompics =\
Ham el kak raz indz petqa frame-ic kanchel
ha zgaci inchid e petq chates grum
ete mtacum es vor kompict a, imho IE es ogtagorcum.... ?
Mesrop is offline   Reply With Quote Quote selected
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inspiration, imitation or innovation - how do designers create unique identities? aramx Web sites 1 Jan 16, 2006 13:45
PHP against ASP acid Web Development 1 Aug 6, 2004 21:30
php and mySQL search problem!!! Timewind Web Development 1 Sep 7, 2002 01:22
PHP remote vulnerabilities VX Software Security 0 Mar 4, 2002 19:20


All times are GMT. The time now is 03:38.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
This board was founded on September 29, 2001
Powered by Viper Internet

Affordable Web Hosting | ParevNet

Buy text link