Error

Discussion in 'PHP' started by nrodes, Nov 3, 2008.

  1. #1
    I am making a simple post script:

    <?php

    //Get user input
    $nickname=$_POST("nickname");
    $message=$_POST("message");

    //include chatlist
    include("chatlist.php");

    //switch all the variables down the list
    include("variablechange.php");

    //rewrite chatlist
    $File = "chatlist.php";
    $Handle = fopen($File, 'w');
    $Data = "<?php $display=" $whole " ?>";
    fwrite($Handle, $Data);
    fclose($Handle);

    //redirect
    echo "Your message has been posted. Please wait...";
    include("redirect.php");

    ?>


    I have an error:

    Parse error: syntax error, unexpected T_VARIABLE in C:\Program Files\Abyss Web Server\htdocs\forum\chat.php on line 16

    I am not very good with php. Could somebody help me???
     
    nrodes, Nov 3, 2008 IP
  2. Louis11

    Louis11 Active Member

    Messages:
    783
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    70
    #2
    Change this line
    $Data = "<?php $display=" $whole " ?>";
    PHP:
    To
    $Data = "<?php $display=" . $whole . " ?>";
    PHP:
    You can't concatenate strings like that in PHP - they have to have a period.
     
    Louis11, Nov 3, 2008 IP
  3. Tarkan

    Tarkan Peon

    Messages:
    491
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You should definitely secure this:
    $nickname=$_POST("nickname");
    $message=$_POST("message");

    filter the $_POST variables if you are using $nickname or $message with a database, or you'll get hacked easily.
     
    Tarkan, Nov 3, 2008 IP