www.webdeveloper.com
Results 1 to 2 of 2

Thread: unexpected T_ENCAPSED_AND_WHITESPACE

  1. #1
    Join Date
    Jun 2007
    Location
    England
    Posts
    448

    Exclamation unexpected T_ENCAPSED_AND_WHITESPACE

    HI just wounderd why my cron has an error:

    PHP Code:
    <?php

    //require and connect
    require("connect.php");

    echo 
    "Updating Progress..........";

    //connect and query buildup and get all infomation
    $query mysql_query("SELECT * FROM buildup"
    or die(
    mysql_error());  
    $result mysql_query($query);
    echo 
    "<br>Connected to database";

    //do while on each result
    while($row mysql_fetch_assoc($result))
    {
    //start of while script


    //some vairiables 
    $expiry $row['endtime'];
    $now time();
    $buildingtype $row['building'];
    $upgrade='bank';

    //the if function on each row to update users whos buildings have finnished
    if($expiry<$now){
    $updateusers mysql_query("UPDATE users SET $upgrade=$upgrade+'1' WHERE id = $row['userid']");
    echo 
    "<br><br>Updated building Successfully";

    $deletelogs mysql_query("DELETE FROM buildup WHERE $expiry < $now");
    echo 
    "<br>Deleted Expired Logs Successfully";

    elseif(
    $expiry>$now){
                                  echo 
    'Nothing to update';
    }else {
                                   echo 
    'Error! Thats not good';
    }
    //end of while script


    ?>
    the error is on this line:

    PHP Code:
    $updateusers mysql_query("UPDATE users SET $upgrade=$upgrade+'1' WHERE id = $row['userid']"); 
    please help me as my progress is on hold until this can be rectified
    Last edited by mitchell; 05-25-2008 at 09:43 PM.

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,537
    The parser gets confused with associative array elements with quoted indexes inside of double-quoted strings. Either use concatenation, or "complex variable notation":
    PHP Code:
    $updateusers mysql_query("UPDATE users SET $upgrade=$upgrade+'1' WHERE id = {$row['userid']}"); 
    "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

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