www.webdeveloper.com
Results 1 to 3 of 3

Thread: Help... Fatal error: Function name must be a string in E:...

  1. #1
    Join Date
    Oct 2010
    Posts
    4

    Help... Fatal error: Function name must be a string in E:...

    Hi, Im pretty new to php scripting and im confused as to why im recieving the error when trying to send mail through an online contact form:

    Fatal error: Function name must be a string in E:\Domains\a\absolutionsaxophonequartet.com\user\htdocs\formhandler.php on line 10

    the script i've written is as follows...





    <?php

    /* subject and email variables */

    $emailSubject = 'Email Through Website';
    $webMaster = 'fraser@absolutionsaxophonequartet.com';

    /* Gathering Data Variables */

    $email = $_POST('youremail');
    $name = $_POST('yourname');
    $subject = $_POST('subject');
    $content = $_POST('content');

    $body = <<<EOD
    <br><hr><br>
    Email: $youremail <br>
    Name: $yourname <br>
    Subject: $subject <br>
    Content: $content <br>
    EOD;

    $headers = "From: $youremail\r\n";
    $headers .= "Content-type: text/html\r\n";
    $success = mail($webMaster, $emailSubject, $body, $headers);

    /* Results Rendered as HTML */

    $theResults = <<<EOD
    <html>
    <head>
    <title>Thank You</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    body {
    background-color: #f1f1f1;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-style: normal;
    line-height: normal;
    font-weight: normal;
    color: #666666;
    text-decoration: none;
    }
    -->
    </style>
    </head>

    <div>
    <div align="left">Thank you for getting in touch! Your email will be answered very soon!</div>
    </div>
    </body>
    </html>
    EOD;
    echo "$theResults";

    ?>



    If anyone could offer any solutions id be really grateful....i know its probably something stupid but im new to this and its 5 am and i've been trying to find answers on the net for hours...

    Thanks very much!

    Fraser

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    You are using parentheses for array keys when they should be square brackets:

    PHP Code:
    // correct:
    $_POST['field_name']

    // wrong:
    $_POST('field_name'); 
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Oct 2010
    Posts
    4
    fantastic thanks very much!

    I appreciate it!

    Fraser

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles