PHP Programming

Posted on 2012-08-21
Last Modified: 2012-08-21
My OS is win 7 64 bit and I am trying to write a short PHP file, but I am getting an error just after the line : include ('rightbar.php').  The error is :
PHP Parse error: syntax error, unexpected '}' in C:\wamp\www\sattv\icontact.php on line 19
I am using the wamp App for this exercise and the file is saved in the above directory.
If I leave the following line, header('Location:');
the error is on that line, and if I were to comment out this line, then the error is on the next line of  the code at '}'
The error for the '}' is  
PHP Parse error: syntax error, unexpected '}' in C:\wamp\www\sattv\icontact.php on line 19

I am just getting into PHP and trying to create some practice Apps. Any help will be appreciated.   Please let me know what I am doing wrong.  thank u.  
The code is :

$value = $_GET['mail'];

if (empty($value) || $value == "Your Primary Email"){

//      $handle = fopen('icontactlist.txt', 'a');
//      fwrite($handle, " ".$value);
//      fclose($handle);

include ('rightbar.php')
Question by:jegajothy
    LVL 12

    Assisted Solution

    You don't have a semicolon at the end of this line:
    include ('rightbar.php')
    It should be
    include ('rightbar.php');

    Author Comment

    in response to zappafan, when I corrected it, and compiled and published it, the error is now:
    PHP Notice: Undefined index: mail in C:\wamp\www\sattv\icontact.php on line 7 PHP Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\sattv\icontact.php:5) in C:\wamp\www\sattv\icontact.php on line 10
    fyi, line 7 = $value = $_GET [ 'mail'];
    and line 10 is :  header('Location:');

    My apologies and thank u for noting that missing ;.
    LVL 12

    Accepted Solution

    Right.  You're assuming that there is a GET variable named "mail" and if it isn't set, and you have errors on, you'll get that warning.

    I usually write lines like that as such:
    $value = isset($_GET['mail']) ?  $_GET['mail'] : "Your Primary Email";
    if ($value == "Your Primary Email"){

    Open in new window

    Now you don't have to check if $value is empty, because it's guaranteed to be defined.
    LVL 82

    Assisted Solution

    by:Dave Baldwin
    You get the new error message because you have HTML and text output before you have the 'header' statement.  Since 'header's must be sent before any content, that causes an error.  Even a single space at the beginning of your PHP file can cause that.  You can use 'output buffering' to get around that limitation.

    Author Closing Comment

    Thank u for your sharp eyes.  Goes without saying, your tons of experience can spot a boo boo a mile way.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now