/    Sign up×
Community /Pin to ProfileBookmark

ShoutBox Help!

This thred is for questions that have to do with our shout box. We decided to start a new thred so we stop posting hundreds of threds that all have to do with the same thing. Jona, we are posting the code so you can help us better cause we were having some mis-communication problems! Here is our current code:

[b]EDIT:[/b] Look down a couple posts to get the script to help us!

Our current problem is the spaces problem we were disscussing in the other thred! Thanks for all your help and help is welcomed from all others as well. ?

to post a comment
PHP

88 Comments(s)

Copy linkTweet thisAlerts:
@sciguyryanMar 08.2004 — Ok, I'll post a link in the old threads so that they will reply to this thread.



Jona *Or anyone else interested* here is the link o you can see for your self ?

http://mjdimick.zacknetwork.net/shout.php
Copy linkTweet thisAlerts:
@sciguyryanMar 08.2004 — Just remove the php tags then.... Some of the reg exps are escaped too.
Copy linkTweet thisAlerts:
@The_CheatMar 08.2004 — Why are you guys using a txt file to store the info. I thought you had unlimited MySQL databases? Mysql is always a better choice than txt if you have the choice to pick between em.
Copy linkTweet thisAlerts:
@JickauthorMar 08.2004 — My server does not have unlimited mysql's!!! just one but unlimited storage!
Copy linkTweet thisAlerts:
@The_CheatMar 08.2004 — oh, ok, but then, still why? you can have plenty of tables in your db's....
Copy linkTweet thisAlerts:
@sciguyryanMar 08.2004 — We will be releasing it to the public so, we want as any people as possible to be able to use it without having to do to much to set it up.

but, that is not the point of this thread. ?
Copy linkTweet thisAlerts:
@JickauthorMar 08.2004 — I'm attaching the file that were working on so people can help. This forum screws it up if we post it on here directly. ?

[upl-file uuid=65bd94cb-99a5-4d60-81e2-e71195a1fb82 size=5kB]shout.txt[/upl-file]
Copy linkTweet thisAlerts:
@The_CheatMar 08.2004 — i noticed you used a regular expression to stop html code. You are better off using [URL=http://us3.php.net/htmlspecialchars]htmlspecialchars()[/URL]

you do it like this:
[code=php]
$variable = htmlspecialchars($variable);[/code]
Copy linkTweet thisAlerts:
@JickauthorMar 08.2004 — Hmm... We'll probably do that then! Thanks... ?
Copy linkTweet thisAlerts:
@JonaMar 08.2004 — [font=arial]Try using this and putting back in the original regular expressions (the one I gave you with the w takes out spaces).[/font]

[font=courier]

$comfile = file($datfile);

if (trim($c) != "" && trim($c) != "[i][/i]" && trim($c) != "[b][/b]" && trim($c) != "[u][/u]" && trim($c) != "[s][/s]") {

$fd = fopen ($datfile, "w");

[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JickauthorMar 08.2004 — Thanks Jona! Where exactally would I put that... I tried just anywhere but it didn't seem to work.

I have been doing some more research and found this:[code=php]$message = $_POST['c'];
if (!ereg("^[A-Za-z0-9@.,/:)(}{_ ]{3,15}$",$message))
{ echo "You must enter a valid message!."; exit; }[/code]
That works and dosn't allow anything but what I want, but it also allows messages with just spaces. Is there something I could add to that to make it allow spaces but not messages that are just spaces? I think If I can get this to work generally then I would be able to impliment it into the tags as well. Thanks.
Copy linkTweet thisAlerts:
@JonaMar 08.2004 — [i]Originally posted by mjdimick [/i]

[B]Thanks Jona! Where exactally would I put that... I tried just anywhere but it didn't seem to work.[/b][/quote]


[font=arial]The first line and last line depict where it should be. Don't you recognize your own code? ? [/font]

[i]Originally posed by mjdimick[/i]

[b]I have been doing some more research and found this:[code=php]$message = $_POST['c'];
if (!ereg("^[A-Za-z0-9@.,/:)(}{_ ]{3,15}$",$message))
{ echo "You must enter a valid message!."; exit; }[/code]
That works and dosn't allow anything but what I want, but it also allows messages with just spaces. Is there something I could add to that to make it allow spaces but not messages that are just spaces? I think If I can get this to work generally then I would be able to impliment it into the tags as well. Thanks. [/B][/QUOTE]


[font=arial]Just take the space out of it, then see how it works.[/font]

[font=courier]

$message = $_POST['c'];

if (!ereg("^[A-Za-z0-9@.,/:)(}{_
]{3,15}$",$message))

{ echo "You must enter a valid message!"; exit; }

[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JickauthorMar 08.2004 — Oh! Stupid me lol...

Umm... I tried taking out the space but then it dosen't allow any spaces whatsoever! I have still been researching but haven't found any thing about it yet! ?
Copy linkTweet thisAlerts:
@JickauthorMar 08.2004 — Well I have been googling for hours now and have not found what I need so hopfully you will be able to help me. ?

I have it so it won't allow totally blank messages but I still need to figure out how to make it so it won't allow spaced messages which create the illusion that it's a blank message. I want to be able to still allow spaces in the message like this "this is a spaced message" but at the same time I don't want to allow this kind of message " " because that is what the problem is. I'm sure it's possible but I just can't find out how to do it! I sure hope you know though. :p
Copy linkTweet thisAlerts:
@JickauthorMar 08.2004 — I just thought of something else. I will need a script which will compact many spaces to just one space so they can't enter a message like this "this_______is a message". The underscores represent the spaces. I had to use underscores cause this forum seems to do what I want by compacting the spaces. Thanks again for your help. ?
Copy linkTweet thisAlerts:
@JonaMar 08.2004 — [font=arial]For that, use:[/font]

[code=php]
$c = str_replace(" ", " ", $c);
[/code]


[font=arial]About the regular expression, try replacing the space that was in the original one with s?[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JickauthorMar 08.2004 — [i]Originally posted by Jona [/i]

[B][font=arial]About the regular expression, try replacing the space that was in the original one with s?[/font][/B][/QUOTE]
I just tried the s thing and it didn't work. Here is my code:$message = $_POST['c'];
if (!ereg("^[A-Za-z0-9@.,/:&;)(}{_s]{3,225}$",$message))
{ echo "You must enter a valid message!"; exit; }
[i]Originally posted by Jona [/i]

[B][font=arial]For that, use:[code=php]$c = str_replace(" ", " ", $c);[/code][/font][/B][/QUOTE]
How does that compact the spaces?
Copy linkTweet thisAlerts:
@JonaMar 08.2004 — [i]Originally posted by mjdimick [/i]

[B]I just tried the s thing and it didn't work.[/b][/quote]


[font=arial]I don't see a question mark after the s. :rolleyes:[/font]

[i]Originally posted by mjdimick[/i]

[b]How does that compact the spaces? [/B][/QUOTE]


[font=arial]Misread. :p Your last sentence confused me. If you're outputting it as HTML, it will automatically compact itself. If you put a bunch of spaces after a word on any of your web pages, the same thing will happen. What's to compact?[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JickauthorMar 08.2004 — Oh I didn't know it required a question mark. Silly me! :p

Oh well I tried typing in a message with a bunch of spaces in it and it does compact them but when looking in the source it shows them so that kinda bothered me but I guess it's ok if you say so! ?
Copy linkTweet thisAlerts:
@JonaMar 08.2004 — [i]Originally posted by mjdimick [/i]

[B]Oh well I tried typing in a message with a bunch of spaces in it and it does compact them but when looking in the source it shows them so that kinda bothered me but I guess it's ok if you say so! ? [/B][/QUOTE]


[font=arial]lol. I don't think it really matters. If it bothers you, you could try running a for() loop and making sure there aren't two or more spaces in a row, and if there are, replace them with one. But it really isn't necessary--and how often do people put more than one space (except for typos)? I don't think you're going to have a million people go to [b]your[/b] shoutbox, just to try to screw it up. ? [/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JickauthorMar 08.2004 — Yeah I guess your right. Thanks.

I just tried it with the question mark included and it still doesn't work...? Here is my code now:$message = $_POST['c'];
if (!ereg("^[A-Za-z0-9@.,/:&;)(}{_s?]{3,225}$",$message))
{ echo "You must enter a valid message!"; exit; }
I'm really sorry that I keep pestering you but this little thing is being stubern lol...
Copy linkTweet thisAlerts:
@JonaMar 08.2004 — [font=arial]I wasn't sure if it was going to work, that's why I said try it. ? In fact, you might as well try replacing the s with a normal space, but keeping the question mark. I don't know if that will help or not, but it's worth a try--anything is, when you're dealing with Regular Expressions.

There is no if references available in RegExps, so you have to make due with exclusions. In other words, you can't say "if message is only spaces in between [this_ubb] and [/this_ubb]" in RegExps, you have to say, "echo text when you find this string."[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JickauthorMar 08.2004 — Hmm... the space with question mark did not work either. I'm wundering if there is a better or easier way to make sure they don't have a message comprised of just spaces and that it actually has content in it? I ask because this is just not working out and I'm getting tired of trying all this different stuff and it never working. ?
Copy linkTweet thisAlerts:
@JonaMar 08.2004 — [font=arial]Did that if statement ever work for you? If not, upload another .txt file with the updated code (and the if statement included).[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JickauthorMar 08.2004 — No! That if statement never worked. I deleted it and forgot what it was but I will post my current file. Thanks for all your help. I really do appreciate it! ?

[b]EDIT:[/b] I will take help from anybody else who can!

[upl-file uuid=4c1a3e01-cb8b-4500-ac5e-81b2ccbb9487 size=4kB]shout.txt[/upl-file]
Copy linkTweet thisAlerts:
@JonaMar 08.2004 — [font=arial]You know what, just email me the whole dadgum script: [email][email protected][/email]. That way I can put it on my local host and try to figure it out more quickly.[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JickauthorMar 08.2004 — I sent it to you! Thanks for your help! ?
Copy linkTweet thisAlerts:
@sciguyryanMar 08.2004 — WOW! Youve been busy. Michael any succeses?
Copy linkTweet thisAlerts:
@JickauthorMar 08.2004 — Well nothing really good to report but I sent the files to Jona and he's working on them on his server because I couldn't figure it out after many trys! ?
Copy linkTweet thisAlerts:
@JonaMar 08.2004 — [i]Originally posted by mjdimick [/i]

[B]Well nothing really good to report but I sent the files to Jona and he's working on them on his server because I couldn't figure it out after many trys! ? [/B][/QUOTE]


[font=arial]I'm having to re-code some parts because they don't work on my server. Mainly because I have a very strict install of PHP, so things must be coded differently.[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JickauthorMar 08.2004 — That's probably a good idea because then it will be more compadible with different servers once we get a better host!
Copy linkTweet thisAlerts:
@sciguyryanMar 08.2004 — Yea! Sen as this can be used by anone then ?
Copy linkTweet thisAlerts:
@sciguyryanMar 08.2004 — A question for you Jona - how do you use this:

[code=php]
<?php
header('WWW-Authenticate: Negotiate');
?>
[/code]



I mean how do you set the password and username for it?
Copy linkTweet thisAlerts:
@JonaMar 08.2004 — [i]Originally posted by sciguyryan [/i]

[B]A question for you Jona - how do you use this:



[code=php]
<?php
header('WWW-Authenticate: Negotiate');
?>
[/code]



I mean how do you set the password and username for it? [/B][/QUOTE]


[font=arial]I think it has something to do with .htaccess, not PHP. That's a guess, though, I've never used it. I've always just used .htaccess for logins, but that may be to ensure that the person is logged in on a PHP page after logging in through .htaccess.[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@sciguyryanMar 08.2004 — Ok, thanks....
Copy linkTweet thisAlerts:
@JonaMar 08.2004 — [font=arial]This works for me...[/font]

[b][J]ona[/b]

[upl-file uuid=a05d5bd7-f004-43e0-909e-8761f62699d8 size=4kB]shoutbox.txt[/upl-file]
Copy linkTweet thisAlerts:
@JickauthorMar 08.2004 — Yes! It works... But the tags are still allowing blank messages. If i enter [ b ]<- space here ->[ / b ] it will still allow it! Hmm...
Copy linkTweet thisAlerts:
@sciguyryanMar 08.2004 — ? Noooo!
Copy linkTweet thisAlerts:
@JickauthorMar 08.2004 — [i]Originally posted by sciguyryan [/i]

[B]:'( Noooo! [/B][/QUOTE]Yeah sorry! I just found out too. :(
Copy linkTweet thisAlerts:
@JonaMar 08.2004 — [i]Originally posted by mjdimick [/i]

[B]Yes! It works... But the tags are still allowing blank messages. If i enter [ b ]<- space here ->[ / b ] it will still allow it! Hmm... [/B][/QUOTE]


[font=arial]It works fine for me... I've modified part of the code, see if it works for you now. (This should be renamed to shout.php.)[/font]

[b][J]ona[/b]

[upl-file uuid=54e01e59-842e-4acd-b30c-2ea8e06abdd1 size=4kB]shoutbox.txt[/upl-file]
Copy linkTweet thisAlerts:
@JickauthorMar 08.2004 — I just tried that one and it is still the same result. Go [URL=http://mjdimick.zacknetwork.net/shout.php]here[/URL] and you can see for yourself. ?
Copy linkTweet thisAlerts:
@JonaMar 08.2004 — [font=arial]Oh I see what the problem was. I fixed it.[/font]

[b][J]ona[/b]

[upl-file uuid=a8bd922e-9926-4dc6-bd1a-780c911ece0f size=4kB]shoutbox.txt[/upl-file]
Copy linkTweet thisAlerts:
@JickauthorMar 08.2004 — Ok now we're getting somewhere. It now does not allow one space inbetween but if I put in more than one it allows it!
Copy linkTweet thisAlerts:
@sciguyryanMar 08.2004 — All we ned to do now is make it so that the space checker checks for multiple versions of the spaces!


Great work though Jona!
Copy linkTweet thisAlerts:
@JonaMar 09.2004 — [font=arial]By the grace of mod, lol, our pyro has given me the answer. Now I could have figured this out, but it would have taken me a couple more hours, so I went ahead and talked to him. ? I do need to brush up on my Regular Expressions skills, though. :p [/font]

[b][J]ona[/b]

[upl-file uuid=9384bab5-879d-4006-ade2-21c137a555b6 size=4kB]shoutbox.txt[/upl-file]
Copy linkTweet thisAlerts:
@JickauthorMar 09.2004 — Oh thank you Jona and thank you Pyro! It's now working but how can I get this to work for my [color] and [font] tags as well? Right now it's not. I was thinking I would change this line:if(preg_match("/[(b|i|u|s)]s*[/\1]/", $_POST['c'])){
echo("You must enter a valid message!"); exit;
}
To this line:if(preg_match("/[(b|i|u|s|color|font)]s*[/\1]/", $_POST['c'])){
echo("You must enter a valid message!"); exit;
}
But wasn't sure. Would there be anything else to change as well? Thank you so much for all your help.
Copy linkTweet thisAlerts:
@JonaMar 09.2004 — [font=arial]Yeah it should look just like that.[/font]

[font=courier]

if(preg_match("/[(b|i|u|s|color|font)]s*[/1]/", $_POST['c'])){

echo("You must enter a valid message!"); exit;

}

[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JickauthorMar 09.2004 — Hmm... I just tried it and it didn't work. Maybe it's the fact that with the other tags it is just the simple one letter but with the [color] and [font] tag you can specify it by doing this [font=curior] and [color=red] and in there if it is defined as just [color] or just [font] it won't incompass this other way [font=curior], [color=red]. Does that make sense? That's the last problem I believe. ?
Copy linkTweet thisAlerts:
@JonaMar 09.2004 — [font=arial]Yeah, I didn't think about that. Hmm, try this one:[/font]

[font=courier]

if(preg_match("/[(b|i|u|s|color=.+|font=.+)]s*[/1]/", $_POST['c'])){

echo("You must enter a valid message!"); exit;

}

[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JickauthorMar 09.2004 — Hmm... That didn't work but it looks like you understood what I mean. Thanks again for your help. ?
Copy linkTweet thisAlerts:
@JickauthorMar 09.2004 — Looks like Jona is offline now and didn't answer before he got off. I just wanted to say that I will accept answers from anybody who knows such as Pyro cause I know he helped Jona figure out the other part. ?
Copy linkTweet thisAlerts:
@JonaMar 09.2004 — [font=arial]I've almost got it figured out, but I'm off to bed now. I'll work on it when I get up in a few hours.[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JickauthorMar 09.2004 — Oh ok... cool! Thanks! Your the best! ?
Copy linkTweet thisAlerts:
@pyroMar 09.2004 — This would probably be the easiest way:

[code=php]if(preg_match("/\[(b|i|u|s|color=.+|font=.+)\]\s*[\/(\\1|color|font)\]/", $_POST['c'])) {
echo("You must enter a valid message!");
exit();
}[/code]
Copy linkTweet thisAlerts:
@JonaMar 09.2004 — [i]Originally posted by mjdimick [/i]

[B]Oh ok... cool! Thanks! Your the best! ? [/B][/QUOTE]


[font=arial]Evidently not. ? I'm trying, though. Pyro is just better, as are a lot of people. I'm still new at this, though. Regular expressions rawk, but I'm not very good at them... yet. I'm working on it though! ?[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JickauthorMar 10.2004 — Thank you Pyro and Jona...

It's all working perfectly now thanks to you guys. You can go [URL=http://mjdimick.zacknetwork.net/shout.php]here[/URL] to see and test it if you feel like it. Once again, thank you for all your help. ?
Copy linkTweet thisAlerts:
@ConorMar 10.2004 — make it so it doesnt redirect you to a new page if you dont enter a valid name.
Copy linkTweet thisAlerts:
@JickauthorMar 10.2004 — We have actually been working on that but you can post any more suggestions you have in our thred in the general forum. Thanks. ?
Copy linkTweet thisAlerts:
@sciguyryanMar 10.2004 — [i]Originally posted by mjdimick [/i]

[B]Thank you Pyro and Jona...

It's all working perfectly now thanks to you guys. You can go [URL=http://mjdimick.zacknetwork.net/shout.php]here[/URL] to see and test it if you feel like it. Once again, thank you for all your help. ? [/B]
[/QUOTE]



Great! thanks Pyro and Jona!
Copy linkTweet thisAlerts:
@JickauthorMar 12.2004 — It's me again! I have a new question. It has to do with the text files that the messages are saved to. Besides using a database such as MySQL, what is the best way to write the info to the files and what is the best file type to use. I ask this because we want to setup the text files in such a way that we can eaisily find a certain message in the file to be able to delete it (for the admin panel were making). Right now the messages are pretty much one after another on a single line. Unless we in-cased each message in special tags inside the file I would think it would be very hard to setup any type of delete mecinisum. ?
Copy linkTweet thisAlerts:
@JonaMar 12.2004 — [font=arial]The best filetype would probably be text, but it really doesn't matter if you have a good host. PHP can read and write to any ASCII type file (and even some binary files, such as images). Sometimes, to avoid direct access to the data (text) files, you can use a different extension and restrict direct access to that filetype, but that's not essential.

As far as the deletion ability in the administration control panel, I'd suggest splitting the posts with a certain character (in Dat_Forum, I used the | character, and converted all of the pipes in each message to their ASCII entity matches [&amp;#128; in this case]). This way, you could get each post, by number, [url=http://php.net/explode]explode()[/url] it into an array, and get whichever post it was to be deleted.[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JickauthorMar 12.2004 — I was wundering if you could either pm me the file or post it here. The one that has to do with deleting from dat_forum??? It's so I can learn from example. I understand if you don't want to. I will just try to find it on my own then. ?
Copy linkTweet thisAlerts:
@JonaMar 12.2004 — [font=arial]You know what, I never created it so that you could click a post to delete it. I have each post in a different file, but the method I proposed (exploding it) ought to work fine. (The replies, name, icon, etc. are done this way in Dat_Forum.)[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JickauthorMar 12.2004 — Oh ok... Thanks. ?

I thought of one more. Is there a function in php to clear all the contents of a text file? Not delete the file but just clear all the contents. Also could I set it up to make it insert a message to the text file after clearing it? Thanks. ?
Copy linkTweet thisAlerts:
@JonaMar 12.2004 — [font=arial]Yes, you can use this:[/font]

[code=php]
<?php
# Data file
$file = "data.txt";

# Take out all text and just
# leave the quotes and parentheses,
# and you'll wind up with a blank file
$info = "This is the new data inside the text file.";

$handle = @fopen($file, "w");
fwrite($info);
fclose($handle);

?>
[/code]


[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JickauthorMar 12.2004 — It's working great! Thanks a million! ?
Copy linkTweet thisAlerts:
@JickauthorMar 12.2004 — Ok, here is an attachment of a file I'm working on. As you can see it will delete the desired line in the file by specifying the line number in the script. I plan to add this into my proccessor script. I want to change it a bit but I need help. How can I make it so the the user (will only be admins) can insert something like this into the message textarea to make it delete the line:

[b]@delete=3@[/b]

In this example by entering that in the textarea the script would delete line three. The @ signs are just to in-case it so it won't get messed up if included in other code. I have got the hard part finished. I'm sure what I want isn't hard but I just don't know how. I would greatly appreciate the help. ?

[upl-file uuid=448de719-bd15-4171-88b7-c17bb2adbf89 size=571B]test.txt[/upl-file]
Copy linkTweet thisAlerts:
@JickauthorMar 12.2004 — I have now tried a couple different things but they didn't work. I really need help with this. I'm sure it is something very stupid that I can't figure out. Thanks. ?
Copy linkTweet thisAlerts:
@JonaMar 12.2004 — [font=arial]It wouldn't be very secure, seeing as anyone would be able to delete a post if you deleted a post depending on what was put into the message.[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JickauthorMar 13.2004 — Well the secret code will be something hard to guess that only admins know in the end. This function would be for deleting messages that are abusive or un-wanted without having to clear the whole thing. ?
Copy linkTweet thisAlerts:
@JonaMar 13.2004 — [i]Originally posted by mjdimick [/i]

[B]Well the secret code will be something hard to guess that only admins know in the end. This function would be for deleting messages that are abusive or un-wanted without having to clear the whole thing. ? [/B][/QUOTE]


[font=arial]You could just go in and edit the file. :p [/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JickauthorMar 13.2004 — Well see I had made a thing to edit the file but I plan to have more than one admin and I can't trust other people to access the file. That's why I just wanted this little code so all they can do is delete the line. Also this makes it more easyier cause all you do is type in the code and boob, it's done. I also kinda think it would make it uniqe because it would make it kinda like IRC in the way of entering command codes. ?
Copy linkTweet thisAlerts:
@JickauthorMar 13.2004 — I have been thinking about it and have come up with this way. I want it like this. If a admin inserts [b]@delete=@[/b], [b]@delete=0@[/b], or [b]@delete=6420@[/b] it will do nothing. Because [b]@delete=@[/b] would be blank (no number specified) and [b]@delete=0@[/b] would be 0 which is no line specified and [b]@delete=6420@[/b] would be no line cause I oveously will never have that many lines. So the only valid way would be to do it like this:

[b]@delete=10@[/b]

Or any number which is a valid number in the file. The script should look at the number and see if that line is there and if it is then delete it! If the line isn't there echo an error telling them it's not a valid line to delete. I hope that explains it better. I have been doing reseach and this one is stumppin me big time. ?
Copy linkTweet thisAlerts:
@JickauthorMar 13.2004 — 

Will this work:
----------------------------------------------------------------------



<?php

[b]if (preg_match("/@delete=(.+?)@/", $_POST['c'])) {[/b]

$filename = "shout.txt"; // The file which holds all the data.

$rowToDelete = "[b](.+?)[/b]"; // This is the line that needs to be deleted.

// $rowToDelete = 1;

$arrFp = file( $filename ); // Open the data file as an array.

$numLines = count( $arrFp ); // Count the elements in the array.

$fp = fopen( $filename, "w" ); // Open the file for writing.

for($i=0; $i<$numLines; $i++) // Overwrite the content except the line to be deleted.

{

if($i != ($rowToDelete-1) )

fwrite($fp, $arrFp[$i]);

}

fclose( $fp ); // Close the data file.

[b]}[/b]

?>


----------------------------------------------------------------------
The parts in bold are what I added. Thanks for your help! ?
Copy linkTweet thisAlerts:
@JonaMar 13.2004 — [font=courier]

if (preg_match("/@delete=(d)@/", $_POST['c'], $rowToDelete)) {

[/font]

[font=arial]If $rowToDelete ends up as an array, add this line after the above code:[/font]

[font=courier]

$rowToDelete = $rowToDelete[0];

[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JickauthorMar 13.2004 — 

So this is what it should look like:
----------------------------------------------------------------------



<?php

[b]if (preg_match("/@delete=(d)@/", $_POST['c'], $rowToDelete)) {

$rowToDelete = $rowToDelete[0];[/b]


$filename = "shout.txt"; // The file which holds all the data.

[b]Should I remove this -->[/b] $rowToDelete = "(.+?)"; // This is the line that needs to be deleted.

$arrFp = file( $filename ); // Open the data file as an array.

$numLines = count( $arrFp ); // Count the elements in the array.

$fp = fopen( $filename, "w" ); // Open the file for writing.

for($i=0; $i<$numLines; $i++) // Overwrite the content except the line to be deleted.

{

if($i != ($rowToDelete-1) )

fwrite($fp, $arrFp[$i]);

}

fclose( $fp ); // Close the data file.

}

?>


----------------------------------------------------------------------
The parts in bold are what I changed. Thanks again for the help. ?
Copy linkTweet thisAlerts:
@JonaMar 13.2004 — [font=arial]Yes you should remove that, because if you leave it in there, it tries to delete a number that is actually a string, and the result is usually an error. After taking the last bold part of your code out, does it work?[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JickauthorMar 13.2004 — Actually I haven't even tried it yet lol...

I was just trying to get a starting point. I was asking before I upload so I atleast had a half way good code so I didn't screw up my files! I will upload now! ?
Copy linkTweet thisAlerts:
@JickauthorMar 13.2004 — Ok, it's not doing anything. I thought I would post my entire shout_proccess.php file so you can look in it and see what might be wrong. The new part is towards the top of the file just so you know. Thanks for your help. ?

[upl-file uuid=2f00b619-666a-4606-b8b8-e1fee25173a7 size=5kB]shout_proccess.txt[/upl-file]
Copy linkTweet thisAlerts:
@JickauthorMar 14.2004 — I really need help with this! ?
Copy linkTweet thisAlerts:
@JickauthorMar 18.2004 — Hey Jona! Where did you disappear to? I would really like to call this project done but I can't until I get this last function working and I can't figure it out. Thanks for your help. ?
Copy linkTweet thisAlerts:
@JonaMar 18.2004 — [i]Originally posted by mjdimick [/i]

[B]Hey Jona! Where did you disappear to? I would really like to call this project done but I can't until I get this last function working and I can't figure it out. Thanks for your help. ? [/B][/QUOTE]


[font=arial]I'm sorry I don't have time right now. I can't help you maybe for another two weeks.[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@sciguyryanMar 20.2004 — Oh, sorry to hear that.
Copy linkTweet thisAlerts:
@JonaMar 22.2004 — [i]Originally posted by sciguyryan [/i]

[B]Oh, sorry to hear that. [/B][/QUOTE]


[font=arial]Don't be sorry for me--I'm in a Los Angeles hotel (a Marriot, if you know what that is), having a grand time! ? [/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JickauthorMar 22.2004 — Well that's cool! ?

Have fun...

See you when you get back around. ?

I'll be glad once you are so we can finish. ?
Copy linkTweet thisAlerts:
@sciguyryanMar 22.2004 — [i]Originally posted by Jona [/i]

[B][font=arial]Don't be sorry for me--I'm in a Los Angeles hotel (a Marriot, if you know what that is), having a grand time! ? [/font]



[b][J]ona[/b] [/B]
[/QUOTE]


Very nice Jone - I wish I was there ?
Copy linkTweet thisAlerts:
@JickauthorMar 23.2004 — Well perhaps someone else could try to help since Jona will be gone for a while. If you just read this whole thred and download my latest posted script you will know the problem I'm having and maybe be able to help. I would greatly appreciate it! ?
×

Success!

Help @Jick spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...