SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING o

    please i am having this
    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING ,
    i have gone through the common mistakes but couldnt detect the error please

    PHP Code:
    <?php require_once("include/dataconnect.php");?>
    <?php 
    require_once("include/functions.php");?>
    <?
     $items 
    $_POST['item'];
    foreach (
    $items as $item) {
         list(
    $Pquantity$Pidno) = $item;
         }
         if(
    'POST' === $_SERVER['REQUEST_METHOD']) 
         {
            
    $queryreg mysql_query("
             UPDATE repplac SET Pquantity = 
    $Pquantity WHERE Pidno = $Pidno AND username = $_SESSION['username']")
            }
            
    $emails=mysql_query("SELECT reusers.email
    FROM reusers, wishlist
    WHERE reusers.username = wishlist.Uname"
    )or die(mysql_error());
    $results = (mysql_fetch_assoc($emails)) or die(mysql_error());
    $email$results{'email'};

    $pplresult mysql_query("SELECT * FROM repplac"); 
    $list $row['Sname'] .$row['Pname'] .$row['Psize'] .$row['Pcolour'] .$row['Pquantity'] .$row['Price'];
    while(
    $row mysql_fetch_assoc($pplresult)){
    $list .= $row['Sname'] .$row['Pname'] .$row['Psize'] .$row['Pcolour'] .$row['Pquantity'] .$row['Price']."\n";}

     

     
    $to $email;
           
    $subject "YOUR ORDER LIST FROM REACHEASY";
           
    $headers "From: donotreply@rapsody.co.uk";
           
    $body "$list";
      
           
    mail($to,$subject,$body,$headers);
    $transfer mysql_query("INSERT INTO wishlist SELECT  * FROM repplac")or die(mysql_error());
    $deletetable mysql_query("DELETE FROM repplac")or die(mysql_error());
    redirect_to('youraccount.php');
        
            
    ?>

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Commenting and indenting can help when code isn't clear. There were a few errors in the above code and a few logical mistakes, but I think the following should work the way you wanted it to:
    PHP Code:
    <?php
    require_once("include/dataconnect.php"); 
    require_once(
    "include/functions.php"); 
    if(
    array_key_exists('item'$_POST)){
        
    $items $_POST['item'];
        
    //Loop through $_POST items, updating the database for each item
        
    foreach ($items as $item) { 
            
    $Pquantity intval($item[0]);
            
    $Pidno intval($item[1]); 
            
    $queryreg mysql_query("
                UPDATE repplac
                     SET Pquantity = 
    {$Pquantity}
                     WHERE
                           Pidno = 
    {$Pidno}
                     AND
                           username = '
    {$_SESSION['username']}'
            "
    ); 
        }
        
    //Get Email Address
        
    $emails mysql_query("SELECT reusers.email FROM reusers INNER JOIN wishlist ON reusers.username = wishlist.Uname AND reusers.username = '{$_SESSION['username']}'")or die(mysql_error()); 
        
    $email mysql_result($emails0);
        
        
    //Get list to email user
        
    $list '';
        
    $pplresult mysql_query("SELECT * FROM repplac");   
        while(
    $row mysql_fetch_assoc($pplresult)){ 
            
    $list .= $row['Sname'] .$row['Pname'] .$row['Psize'] .$row['Pcolour'] .$row['Pquantity'] .$row['Price']."\n"
        }
        
        
    //Send email
        
    $to $email
        
    $subject "YOUR ORDER LIST FROM REACHEASY"
        
    $headers "From: donotreply@rapsody.co.uk"
        
    $body "$list"
        
    mail($to,$subject,$body,$headers);
        
        
    //Transfer records to wishlist 
        
    $transfer mysql_query("INSERT INTO wishlist (SELECT  * FROM repplac WHERE username = '{$_SESSION['username']}')");
        
    // Delete temporary records if the above query was successful:
        
    if($transfer !== false){
            
    $deletetable mysql_query("DELETE FROM repplac WHERE username = '{$_SESSION['username']}'");
        }
    }     
    redirect_to('youraccount.php'); 
    ?>
    You had some whole-table emptying going on, but you only want to be removing records allocated to that particular user, so I've fixed that. Give it a go, I haven't verified if there's an error or not but it should be fine.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    its giving this error
    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 5 in /home/reachea2/public_html/updatepplac.php on line 21

    Warning: Cannot modify header information - headers already sent by (output started at /home/reachea2/public_html/updatepplac.php:21) in /home/reachea2/public_html/include/functions.php on line 5

  4. #4
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The second error is ok (kind of), it's basically an error produced by the mysql row. I should have caught that one:

    PHP Code:
    <?php
    require_once("include/dataconnect.php"); 
    require_once(
    "include/functions.php"); 
    if(
    array_key_exists('item'$_POST)){
        
    $items $_POST['item'];
        
    //Loop through $_POST items, updating the database for each item
        
    foreach ($items as $item) { 
            
    $Pquantity intval($item[0]);
            
    $Pidno intval($item[1]); 
            
    $queryreg mysql_query("
                UPDATE repplac
                     SET Pquantity = 
    {$Pquantity}
                     WHERE
                           Pidno = 
    {$Pidno}
                     AND
                           username = '
    {$_SESSION['username']}'
            "
    ); 
        }
        
    //Get Email Address
        
    $emails mysql_query("SELECT reusers.email FROM reusers INNER JOIN wishlist ON reusers.username = wishlist.Uname AND reusers.username = '{$_SESSION['username']}'")or die(mysql_error());
        if(
    mysql_num_rows($emails) == 0){
             exit(
    "No email addresses found for user '{$_SESSION['username']}'");
        }
        
    $email mysql_result($emails0);
        
        
    //Get list to email user
        
    $list '';
        
    $pplresult mysql_query("SELECT * FROM repplac");   
        while(
    $row mysql_fetch_assoc($pplresult)){ 
            
    $list .= $row['Sname'] .$row['Pname'] .$row['Psize'] .$row['Pcolour'] .$row['Pquantity'] .$row['Price']."\n"
        }
        
        
    //Send email
        
    $to $email
        
    $subject "YOUR ORDER LIST FROM REACHEASY"
        
    $headers "From: donotreply@rapsody.co.uk"
        
    $body "$list"
        
    mail($to,$subject,$body,$headers);
        
        
    //Transfer records to wishlist 
        
    $transfer mysql_query("INSERT INTO wishlist (SELECT  * FROM repplac WHERE username = '{$_SESSION['username']}')");
        
    // Delete temporary records if the above query was successful:
        
    if($transfer !== false){
            
    $deletetable mysql_query("DELETE FROM repplac WHERE username = '{$_SESSION['username']}'");
        }
    }     
    redirect_to('youraccount.php'); 
    ?>
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  5. #5
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    it is not updating, the record, and not sending the email, (but i echoed the email, and it came back correct),


Bookmarks

Posting Permissions

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