View Full Version : no compile, no debugger

11-25-2006, 09:47 PM
Sorry to post such a big chuck of code for a first-time post, put I need a second set of eyes on this. It won't compile and I don't have a debugger to go through it (can't seem to make any of the popular ones work :'( )
Here's what it's supposed to do:
double-opt in email address verifier and collector: someone comes to a basic form, types in their name and email. This script checks the form information for errors, makes sure it's not already in a mysql database, makes a uniquely cyphered identifier out of their email, and sends that identifier to them in a link back to the script. When they click on that link, this script grabs the relevant info, throws it in the database and welcomes them into Omerta (pretty much).
I've been all over this code and I still can't figure out where I'm going wrong. Maybe you can.

//collect visitor's name and email from form or address bar
$from = $_REQUEST['user_add'];
$from = urldecode($from);
$frommail = $_REQUEST['email_add'];
$frommail = urldecode($frommail);

//make sure they put something in the form
if(empty($from) || empty($frommail)) {
echo "<h2>Dude, we can't do this without your help!</h2><br>".
"Use your browser's back button to enter your information and try again.";
return 1;

//make sure email address is real.
if(eregi("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $frommail)) {
@mysql_select_db($database) or die( "Unable to select database");
$prequery="Select email from newsletter where email='".$frommail."'";
$exists = mysql_query($prequery) or die("Error #:".mysql_errno()."<br>".mysql_error());
//check for existance in DB
if($row = mysql_fetch_array($exists)) {
<h1>Welcome back, <?php echo $from ?>!<br></h1>
<h3>We're glad you like the newsletter so much, but you don't need to sign up twice.
Thanks to the magic of the internet, you can forward, copy or blind carbon copy
it to anyone, anywhere and all to your little heart's content. That being said,
we hope you don't mind us restricting you to just the one. I mean, come on.
We've got bills to pay, you know?</h3>
return 1;
else {
//turn email into unique ID.
$cypher = "[redacted]";
$formatted_email = preg_replace("/(-|\@|\.)/", "", $frommail);
$h_email= md5("$cypher $formatted_email");

//if validating, put visitor in DB
if($_REQUEST['m'] != "") {
if($h_email == $_REQUEST['m']) {
@mysql_select_db($database) or die( "Unable to select database");
$query="INSERT INTO newsletter VALUES ('".$from."','".$frommail."')";
mysql_query($query) or die(mysql_error());
echo "Congratulations,".$from.". You're now part of the Marco's Taxi".
"family. From now on, every time you walk down the street, you'll gaze ".
"upon your fellow man or woman and wonder: \"Are they one, too?\" ".
"You may be tempted to ask them as much, but be warned. The oath".
" you've sworn is unbreakable...like <a href=\"http://en.wikipedia.org/wiki/Omerta\">Omerta</a>.".
" You're one of us now, paisano. You're made. The world is yours.";
return 1;
} else {
echo "Sorry, this email does not validate. ".
"Go <a href=\"index.html\">back</a> ."
"and try again, buckaroo.";
//if not yet validating, create and send validation email
else {
$url_from = urlencode($from);
$url_mail = urlencode($frommail);
$mail_body = "To validate this email click the following link:\n".
"[URL redacted]signup.php?user_add=".$url_from."&email_add=".$url_mail."&m=".$h_email."\n\n".
"Unfortunately, not every email program knows how to hold together URLs, ".
"so if clicking on the link doesn't work, just cut and past it into the ".
"address bar of your browser.\n".
"And by the way, thanks!";
mail($frommail, "*Marco's Taxi Email Validation*", $mail_body, "From:[redacted]\n");
<p align="left">
<h1>Thanks, <?php echo $from ?>!<br></h1>
&nbsp &nbsp &nbsp &nbsp We've gone ahead and sent an email to
<b><?php echo $frommail ?>
</b> with a link that lets you verify your email with us.
If the email you gave us is wrong or isn't yours, don't worry.
We all screw up every now and again.
Go back and try it again. <br />
&nbsp &nbsp &nbsp &nbsp If everything looks good, <a href="fleet">click
here</a> to gaze once again upon our majestic fleet.
echo "<h2>".$frommail." ain't a real email address!</h2><br>".
"Use your browser's back button to correct your email address."


11-25-2006, 10:34 PM
What errors are you getting or are you getting a blank page?

11-25-2006, 10:41 PM
Thus far, I'm just getting a blank page, so it has to be a compile error...


11-25-2006, 11:17 PM
Blank pages are usually caused by open quotes or open {.

I checked your code and there are a number of "return..." statements. If this code is not within a function, than these have no meaning and I am not sure what the run time results would be.

Edit: In case anyone read that, the source code does have back-slashes to escape the double-quotes.

Also between lines 64 and 65, you are trying to use the . to concatenate two strings, but the . is inside of the double-quoted string on line 64.

11-25-2006, 11:31 PM
I took a second look and my concatenation at line 64 was wrong. Dreamweaver evidently didn't pick that up. Thanks.

Unfortunately, the code still doesn't compile. I'll keep scanning my code and see if I can't find a curly bracket error or something else. It's always the little things that screw up a perfectly good app.

Thanks for the help! :thumbsup:

11-25-2006, 11:34 PM
you should probably setup your server so it reports errors to you rather than dying silently.

11-25-2006, 11:36 PM
I'm on a hosting service.
Any way I can set this up me-self?

11-26-2006, 02:16 AM
Do you ever feel, at times, that if you were any dumber, someone would probably have smothered you in your sleep to save the rest of the world undue anguish?


Turns out, I had an echo statement right at the end that didn't have a ';' to finish it.
Do you see?
DO YOU SEE how easy it is to be a moron?
I'm going to practice my Morrisey impersonation in the corner and then see if I can't wrap the rest of this project up.
Thanks for the help, guys.