Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING

    Hi guys.
    Im a bit new to PHP and mySQL and i've ended up a bit stuck.

    I am getting the following error:
    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /foldername/newarticle.php on line 14

    I have removed any whitespace etc that I can find which leads me to conclude it must be a syntax error. Can anyone help me please? My code is to follow:

    <?php
    require_once('../includes/DbConnector.php');

    if ($HTTP_POST_VARS){

    $connector = new DbConnector();

    $insertQuery = "UPDATE test SET TheArticle = $HTTP_POST_VARS['content'] WHERE test.ID =14 LIMIT 1;

    if ($result = $connector->query($insertQuery)){

    echo '<center><b>Article added to the database</b></center><br>';

    }else{

    exit('<center>Error saving to the database</center>');
    }
    }
    ?>

    Any help would be much appriciated


    Regards
    Pete

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,631
    Thanks
    4
    Thanked 147 Times in 138 Posts
    Missing a closing double quote here:

    Code:
    $insertQuery = "UPDATE test SET TheArticle = $HTTP_POST_VARS['content'] WHERE test.ID =14 LIMIT 1;
    note please use [ php] and [/php] tags around your code. remove the space in the first tag when you use them.

  • #3
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    You're missing an ending quote here:

    $insertQuery = "UPDATE test SET TheArticle = $HTTP_POST_VARS['content'] WHERE test.ID =14 LIMIT 1;"

  • #4
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Still errors

    Hi guys,
    Thanks for your help, but I am still getting this error:

    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/i4visua/public_html/cmsadmin/newarticle.php on line 13

    The way this is suppost to work is as follows:
    There is a simple HTML input box on a page in which the user types information.
    The input box is named thearticle.
    The user clicks submit and the forms action is set to a php page containing the script above.
    This script processes the data retrived from the input box in the previous page and REPLACES the data in ID "14" in the field "TheArticle" in the database "test".

    I can make the script work by entering an actual value such as:
    PHP Code:
    $insertQuery "UPDATE `test` SET `TheArticle` = 'content here' WHERE `test`.`ID` =14 LIMIT 1 ;" 
    but i am trying to use a variable loaded in from a HTML form.

    Any help would be much appriciated

    Regards
    Pete

  • #5
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    the " wants to go before the ;

    [edit]
    and you should do the following for inserting user-data:
    PHP Code:
    $insertQuery "UPDATE test SET TheArticle = '".mysql_real_escape_string($POST['content']."' WHERE id =14 LIMIT 1"
    http://php.net/mysql-real-escape-string
    Last edited by GJay; 12-08-2006 at 03:15 PM.

  • #6
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thankyou,
    in the code, you have used the following:
    PHP Code:
    ($POST['content'
    does this mean I need to declare it???
    e.g.
    PHP Code:
    $message $HTTP_POST_VARS['Message']; 
    (im sorry, like i said, i am new to this)

    Regards
    Pete
    Last edited by i4VisualMedia; 12-08-2006 at 03:24 PM. Reason: put e.h. instead of e.g.


  •  

    Posting Permissions

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