Nodral Posted July 21, 2011 Share Posted July 21, 2011 Hi all I had this working in a dev environment with php 5.2.13, however I have moved it into live which used php 5.3.6 and I'm having issues with my elseif statement. <?php //has user agreed to have admin account? If confirm has not yet been set........... if(!isset($_POST['confirm'])){ include('header.php'); unset($_SESSION['dbsecure']); echo'<div class="pagetext">You are the first to use this application.<br>Would you like to be set up as the main admin user?<br></div> <form method="POST" action=""> <input type="submit" name="confirm" value="Yes"><input type="submit" name="confirm" value="No"> </form>'; //if confirm is set, has form been completed? } elseif(isset($_POST['change'])){ //if form is completed are all variables set? if(isset($ED, $password, $firstname, $lastname, $email, $dept, $workplace, $home, $role)){ //create table $sql="CREATE TABLE pfp_user (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, ed VARCHAR(255) NOT NULL, firstname VARCHAR(255) NOT NULL, lastname VARCHAR(255) NOT NULL, dept VARCHAR(255), workplace VARCHAR(255), home VARCHAR(255), password VARCHAR(255), email VARCHAR(255), role VARCHAR(255) NOT NULL, complete VARCHAR(255) NOT NULL, type VARCHAR(255)) DEFAULT CHARACTER SET utf8"; mysql_query($sql) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $sql . "<br />\nError: (" . mysql_errno() . ") " . mysql_error()); //hash password $password=md5($password); //insert data $sql="INSERT INTO pfp_user (ED, firstname, lastname, dept, workplace, home, password, email, role, complete, type) VALUES ('$ED', '$firstname', '$lastname', '$dept', '$workplace', '$home', '$password', '$email', '$role', 'Yes', 'Allocated')"; mysql_query($sql) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $sql . "<br />\nError: (" . mysql_errno() . ") " . mysql_error()); $_SESSION['output']="Admin User Successfully Registered. Please log in."; $extra = 'index.php'; header("Location: http://$host$uri/$extra"); } //missing data else{ $_SESSION['output']='<div class="pagetext">You have missed some information<br>Please try again</div>'; } } I get the following error PHP Parse error: syntax error, unexpected '}' in /home/httpd/vhosts/client9/web14/web/devsite/pfp/config.php on line 62 Line 62 is the elseif statement. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/242552-php-53-quirk/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 21, 2011 Share Posted July 21, 2011 Taken out of context, the posted code does not produce a php syntax error. You must have something prior to that point in the code or you have a corrupted source file and the copy/paste into the forum post only copied the actual ASCII visible characters. Quote Link to comment https://forums.phpfreaks.com/topic/242552-php-53-quirk/#findComment-1245680 Share on other sites More sharing options...
TOA Posted July 21, 2011 Share Posted July 21, 2011 Nevermind, I read it wrong Quote Link to comment https://forums.phpfreaks.com/topic/242552-php-53-quirk/#findComment-1245681 Share on other sites More sharing options...
Nodral Posted July 21, 2011 Author Share Posted July 21, 2011 Sorted I had a short opening tag earlier in the code. Php 5.3 hates these!!! lol Quote Link to comment https://forums.phpfreaks.com/topic/242552-php-53-quirk/#findComment-1245693 Share on other sites More sharing options...
premiso Posted July 21, 2011 Share Posted July 21, 2011 Php 5.3 hates these!!! lol It doesn't hate them, it just defaults them to off. You can turn them back on in the php.ini file. I generally turn them back on because I like using those tags for my template/view files. Quote Link to comment https://forums.phpfreaks.com/topic/242552-php-53-quirk/#findComment-1245695 Share on other sites More sharing options...
PFMaBiSmAd Posted July 21, 2011 Share Posted July 21, 2011 Php programmers hate short open tags because they result in php code that is not portable between different servers. You should only use short open tags in code that will be used on a server that you own so that you can insure that the setting will always be turned on or you can simply realize that you will spend several orders of magnitude more time troubleshooting problems in code that contains short open tags, then the few seconds you saved in typing time, and never use them, ever. Quote Link to comment https://forums.phpfreaks.com/topic/242552-php-53-quirk/#findComment-1245701 Share on other sites More sharing options...
Nodral Posted July 21, 2011 Author Share Posted July 21, 2011 Generally I use long tags anyway. It was the way I was taught This was probably just a typo Quote Link to comment https://forums.phpfreaks.com/topic/242552-php-53-quirk/#findComment-1245705 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.