Jump to content

PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting


AdRock

Recommended Posts

I have a form with validation that works but i want to seperate php from html.

 

I include the form where i want it and have the php included at the top of the page so th ephp is processed before any html is printed

 

Since doing this i get this error message

 

PHP Parse error:  syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ']'

 

How do i get around this error?  It's pointing to this line

 

$postcode = check_input($_POST['postcode']);

 

And here is the code in question (the first part)

 

<?php
    global $error, $print_again, $register;
    global $first_name, $last_name;
    global $houseno, $street, $town, $county, $postcode, $telephone;
    global $email1, $email2, $username, $password1, $password2; 

    $register = $_POST['register'];

function check_form() { 

    //variables for checking the user's name
    $first_name = check_input($_POST['first_name']);
    $last_name = check_input($_POST['last_name']);

    //variable for checking the user address and telephone
    $houseno = check_input($_POST['houseno']);
    $street = check_input($_POST['street']);
    $town = check_input($_POST['town']);
    $county = check_input($_POST[county']);
    $postcode = check_input($_POST['postcode']);
    $telephone = check_input($_POST['telephone']);

    //variables for checking the user's email
    $email1 = check_input($_POST['email1']);
    $email2 = check_input($_POST['email2']);

    //varaibles for checking the user login credentials
    $username = check_input($_POST['username']);
    $password1 = check_input($_POST['password1']);
    $password2 = check_input($_POST['password2']);

 

and if you need to see this

 

<?php 

error_reporting(E_ALL);

// check the $_GET['page'] variable
$page = ((isset($_GET['page']) && $_GET['page'] != '') ? $_GET['page'] : 'home');
// prevent file browsing
$page=(preg_match('/(\.\.|\/)/i',$page)?'home':$page);
// replace illegal characters
$page = preg_replace('/[^a-zA-Z0-9 \._-]/','',$page);
// check if the requested file exists
$page = (file_exists('./pages/'.$page.'.php') ? $page : 'error');
// include the page include for page title and functions
include_once('./pages/'.$page.'.inc.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>

Link to comment
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.