Irresistable Posted November 1, 2009 Share Posted November 1, 2009 Hello I'm new to the forums. I have made a newsletter script, where you subscribe, and it has a captcha for spam protection. Email activation, etc etc. It's not fully protected, however.. it will head that way. I don't know all my errors yet, as they display one at a time. I'm just going through each error, fix it, and then fix the next one. Here is one I'm stuck with.. "Parse error: syntax error, unexpected $end in /home/jeanie/public_html/Newsletter Beta/include/session.php on line 71" Line 71.. is simply as follows:- ?> I have checked the code thoroughly.. and I can only find one "<?php" and one "?>" I don't know what the code is. I have a feeling it might be something to do with ending the if statements, or functions etc. Here is my script. <?php include("Newsletter Beta/include/database.php"); include("Newsletter Beta/include/mailer.php"); include("Newsletter Beta/include/form.php"); class Session { /* Class constructor */ function Session(){ $this->time = time(); $this->startSession(); } function startSession(){ global $database; //The database connection session_start(); //Tell PHP to start the session function register($subemail, $subuser_code){ global $database, $form, $mailer; //The database, form and mailer object /* Email error checking */ $field = "email"; //Use field name for email if(!$subemail || strlen($subemail = trim($subemail)) == 0){ $form->setError($field, "* Email not entered"); } else{ /* Check if valid email address */ $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*" ."@[a-z0-9-]+(\.[a-z0-9-]{1,})*" ."\.([a-z]{2,}){1}$"; if(!eregi($regex,$subemail)){ $form->setError($field, "* Email invalid"); $subemail = stripslashes($subemail); } else if($database->emailTaken($subemail)){ $form->setError($field, "* Email already been subscribed"); } } /* Captcha error chcking */ $field = "captcha"; //Use field name for gender if (strcmp(md5($subuser_code),$_SESSION['ckey'])){ $form->setError($field, "* Captcha image is incorrect"); } /* Errors exist, have user correct them */ if($form->num_errors > 0){ return 1; //Errors with form } /* No errors, add the new account to the database */ else{ $activ_code = rand(1000000,9999999); if($database->addNewUser($subemail, $activ_code)){ if(EMAIL_WELCOME){ $mailer->sendWelcome($subemail,$activ_code); } return 0; // New user added succesfully }else{ return 2; //Registration attempt failed } } }; $session = new Session; /* Initialize form object */ $form = new Form; ?> Link to comment https://forums.phpfreaks.com/topic/179846-solved-many-errors-within-my-secure-newsletter-script/ Share on other sites More sharing options...
MrXander Posted November 1, 2009 Share Posted November 1, 2009 Try this: <?php include("Newsletter Beta/include/database.php"); include("Newsletter Beta/include/mailer.php"); include("Newsletter Beta/include/form.php"); class Session { /* Class constructor */ function Session(){ $this->time = time(); $this->startSession(); } function startSession(){ global $database; //The database connection session_start(); //Tell PHP to start the session } function register($subemail, $subuser_code){ global $database, $form, $mailer; //The database, form and mailer object } /* Email error checking */ $field = "email"; //Use field name for email if(!$subemail || strlen($subemail = trim($subemail)) == 0){ $form->setError($field, "* Email not entered"); } else{ /* Check if valid email address */ $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*" ."@[a-z0-9-]+(\.[a-z0-9-]{1,})*" ."\.([a-z]{2,}){1}$"; if(!eregi($regex,$subemail)){ $form->setError($field, "* Email invalid"); $subemail = stripslashes($subemail); } else if($database->emailTaken($subemail)){ $form->setError($field, "* Email already been subscribed"); } } /* Captcha error chcking */ $field = "captcha"; //Use field name for gender if (strcmp(md5($subuser_code),$_SESSION['ckey'])){ $form->setError($field, "* Captcha image is incorrect"); } /* Errors exist, have user correct them */ if($form->num_errors > 0){ return 1; //Errors with form } /* No errors, add the new account to the database */ else{ $activ_code = rand(1000000,9999999); if($database->addNewUser($subemail, $activ_code)){ if(EMAIL_WELCOME){ $mailer->sendWelcome($subemail,$activ_code); } return 0; // New user added succesfully }else{ return 2; //Registration attempt failed } } }; $session = new Session; /* Initialize form object */ $form = new Form; ?> You need to double check you're closing all your functions. Link to comment https://forums.phpfreaks.com/topic/179846-solved-many-errors-within-my-secure-newsletter-script/#findComment-948767 Share on other sites More sharing options...
Irresistable Posted November 1, 2009 Author Share Posted November 1, 2009 I did, but sometimes with so many.. it confuses my little brain. Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /home/jeanie/public_html/Newsletter Beta/include/session.php on line 24 Line 24 is $field = "email"; //Use field name for email its on the same file as I posted before and which was corrected. So you could perhaps use the.. includes that are in the code I posted before too. Though the subscribing part is.. <tr> <td width="23%" height="25">Email:</td> <td width="73%"><input name="email" type="text" value="<? echo $form->value("email"); ?>" size="50" maxlength="100" /></td> <td width="4%"> </td> </tr> not all the form, but just the.. bit you'd probably need... let me know if you need anything from the included files. Link to comment https://forums.phpfreaks.com/topic/179846-solved-many-errors-within-my-secure-newsletter-script/#findComment-948787 Share on other sites More sharing options...
Irresistable Posted November 1, 2009 Author Share Posted November 1, 2009 Sorry for double post.. I fixed the above problem. The "}" for function register, was clearly in the wrong place. Link to comment https://forums.phpfreaks.com/topic/179846-solved-many-errors-within-my-secure-newsletter-script/#findComment-948801 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.