Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/242552-php-53-quirk/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/242552-php-53-quirk/#findComment-1245680
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/242552-php-53-quirk/#findComment-1245701
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.