Jump to content

Edit Text File


craygo

Recommended Posts

Good morning php experts,

I have a text file called clients.txt. This file contains admins for my game servers. I also have a database which holds all of my clan members with all info I need.

What I want to do is this:

1. open up the clients.txt file
2. search for "players". this is the second line of the text file
3. insert my desired text after this line and put the rest of the text back

Any help would be cool guys

Thanks

Ray
Link to comment
Share on other sites

[!--quoteo(post=357087:date=Mar 21 2006, 03:48 PM:name=craygo)--][div class=\'quotetop\']QUOTE(craygo @ Mar 21 2006, 03:48 PM) [snapback]357087[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Man you guys have been failing me lately[/quote]

Sorry to hear you had to learn something with out us.

I've noticed that the number of people on the site has declined dramatically the last few days. It's 530 pm here now, and usually when I look at the number of people viewing the form it's 150+ this time of day. Right now it's 16.

I hate to attribute it to the new ads, but that's the only really noticeable change that's taken place.
Link to comment
Share on other sites

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]I hate to attribute it to the new ads, but that's the only really noticeable change that's taken place.[/quote]
It's not so much the new ads, but they process that is used to get them on the page. It's causing a noticable delay when displaying the pages and warnings that scripts are taking too long. Enough of them and people stop coming. And the occasional problems posting code doesn't help either.

Ken
Link to comment
Share on other sites

I am just busting your chops guys!! I have learned so much from you guys here, ads, or no ads I will continue to come and help people out.

It seems like I help people alot more than I ask lately, which is a great thing. I enjoy helping people out cause I will not forget I was there once and always got help here. I have designed over 5 sites, all with php, and have not had something not work that I was trying to do. Of course a little java in the mix helps out. But they range from my Clan site to a few Database driven intranet sites for a couple local companies. One, my site is running their entire invoice and quoting system right from their browser. Enough bragging LOL let me go help some peeps out

Later all

Ray
Link to comment
Share on other sites

[!--quoteo(post=357087:date=Mar 21 2006, 09:48 PM:name=craygo)--][div class=\'quotetop\']QUOTE(craygo @ Mar 21 2006, 09:48 PM) [snapback]357087[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Man you guys have been failing me lately :)

I got it all set.

Ray
[/quote]

Could you post your solution for your problem,
seems like an interesting thing that I can probably use.
Thx!
Grande
Link to comment
Share on other sites

Well it was not really a search and replace type thing. Since I needed to add some data and I could add it anywhere I wanted as long as it was not in the middle of something else, I used this.

[code]// Run Query to get new data
$sql = "SELECT handle, steamid FROM recruit_app WHERE handle = 'JohnnyBravo'";
  $res = mysql_query($sql) or die (mysql_error());
    while ($r = mysql_fetch_array($res)){
      $new = "     \"".$r['handle']."\"\n     {\n      \"name\" \"".$r['handle']."\"\n      \"steam\" \"".$r['steamid']."\"\n      \"admingroups\" \"Recruits\"\n      \"immunitygroups\" \"Recruits\"\n     }\n";
      }
      echo "$new<br /><br />";
$top = file_get_contents($myTextFile, False, NULL, 0, 33);
$bottom = file_get_contents($myTextFile, False, NULL, 34);
$toptext = stripslashes($top);
$bottomtext = stripslashes($bottom);
$newtext = ''.$toptext.''.$new.''.$bottomtext.'';
echo nl2br($newtext);

$inputString = $newtext;[/code]

Ray
Link to comment
Share on other sites

[!--quoteo(post=357313:date=Mar 22 2006, 10:25 AM:name=Grande)--][div class=\'quotetop\']QUOTE(Grande @ Mar 22 2006, 10:25 AM) [snapback]357313[/snapback][/div][div class=\'quotemain\'][!--quotec--]
seems like an interesting thing that I can probably use.
[/quote]

A long time ago I posted some stuff about working with text files...a mini-tutorial if you will.

[a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=63496\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?showtopic=63496[/a]

It was closed almost immeidatly by toplay...I don't think he appreciated the post very much for some reason.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.