craygo Posted March 21, 2006 Share Posted March 21, 2006 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 file2. search for "players". this is the second line of the text file3. insert my desired text after this line and put the rest of the text backAny help would be cool guysThanksRay Quote Link to comment Share on other sites More sharing options...
craygo Posted March 21, 2006 Author Share Posted March 21, 2006 Man you guys have been failing me lately :)I got it all set.Ray Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted March 21, 2006 Share Posted March 21, 2006 [!--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. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 22, 2006 Share Posted March 22, 2006 [!--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 Quote Link to comment Share on other sites More sharing options...
craygo Posted March 22, 2006 Author Share Posted March 22, 2006 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 outLater allRay Quote Link to comment Share on other sites More sharing options...
Grande Posted March 22, 2006 Share Posted March 22, 2006 [!--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 Quote Link to comment Share on other sites More sharing options...
craygo Posted March 22, 2006 Author Share Posted March 22, 2006 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 Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted March 22, 2006 Share Posted March 22, 2006 [!--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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.