Current location: Hot Scripts Forums » Programming Languages » PHP » parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting '}'


parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting '}'

Reply
  #1 (permalink)  
Old 07-04-06, 02:02 PM
unlisted80's Avatar
unlisted80 unlisted80 is offline
Newbie Coder
 
Join Date: Feb 2005
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting '}'

I got this error and i can't figure itout...can someone please help me

Quote:
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting '}' in /homepages/44/d147905660/htdocs/myfolder/refer.php on line 44
Line 44 i got this
Quote:
mail($_POST['email'], $ReferEmailSubject, $message, $headers);

Thank advance
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-04-06, 02:27 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
Errors like this are caused by missing or incorrect syntax, prior to where the error occurred. You should post all the code or at lease all the code up to the mail(...) statement.

If your code contains sensitive information (passwords...) xxxxxx them out.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-04-06, 04:15 PM
unlisted80's Avatar
unlisted80 unlisted80 is offline
Newbie Coder
 
Join Date: Feb 2005
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:

session_start();

require(
"config.php");
include_once(
"$full_path_to_public_program/session.php");

include(
"templates/main.html.php");
include(
"templates/leftside.html.php");
include(
"templates/refer_header.html");

if (isset(
$_POST['send']) AND $_POST['send'] == "1"){
    if (!
preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+@([-0-9A-Z]+\.)+([0-9A-Z]){2,4}$/i'EscapeString($_POST['email']))) {
        
$error .="<div class=\"error\">$RegistrationError[2]</div>";
    }
    if (!isset(
$_POST['sendername']) AND $_POST['sendername'] == ""){
        
$error .= "<div class=\"error\">$RegistrationError[3]</div>";
    }
     if (!
$error){
        
$_POST['senderemail'] = $_POST['sendername'];
        
$check mysql_query("SELECT picid from $pic_tbl where picid = '".valid_id($_POST['pid'])."'") Or die (mysql_error());
        
$row mysql_fetch_array($check);

        
$ReferEmail str_replace("{SENDER}"$_POST['sendername'],$ReferEmail);
        
//$ReferEmail = str_replace("{PASSW}", $_POST['pass'],$ReferEmail);
        
$ReferEmail str_replace("{PHOTO}","<a href=\"$siteurl/?id={$row['picid']}\">{$siteurl}/?id={$row['picid']}</a>",$ReferEmail);

        
$message "<html><head></head><body><br />";
        
$message .= $ReferEmail;
        
$message .= "<br /></body></html>";

        
$headers "From: {$_POST['sendername']} <{$from_address']}>\r\nContent-type: text/html";

        mail($_POST['
email'], $ReferEmailSubject, $message, $headers);

        echo "<tr><td><div class=\"txt_dbrown_bold02\" align=\"center\">$ReferSuccess</div></td></tr></table></td>";
        include("templates/newheader_end.html");
        include("templates/footer.html.php");
        exit;

    } else {
        echo "<tr><td><div style=\"padding:10px; text-align:center\" class=\"txt_dbrown_bold02\">$RecommendToFriend</div></td></tr></table></td>\n";
        include("templates/referform.html.php");
        include("templates/footer.html.php");
        exit;
    }
}
if (isset($_POST['
op']) AND $_POST['op'] == "ds"){
    if (!preg_match('
/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+@([-0-9A-Z]+\.)+([0-9A-Z]){2,4}$/i', EscapeString($_POST['email']))) {
        
$error .="<div class=\"error\">$RegistrationError[2]</div>";
    }

    if (!preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+@([-0-9A-Z]+\.)+([0-9A-Z]){2,4}$/i', EscapeString(
$_POST['senderemail']))) {
        
$error .="<div class=\"error\">$RegistrationError[2]</div>";
    }
    if (!
checkSecurityImage($_POST['security_refid'], $_POST['security_try'])){
        
$error .= "<div class=\"error\">$InvalidSecID</div>";
    }
    if (!isset(
$_POST['email']) AND $_POST['email'] == ""){
         
$error .="<div class=\"error\">$RegistrationError[2]</div>";
    } 
    if (!isset(
$_POST['sendername']) AND $_POST['sendername'] == ""){
        
$error .= "<div class=\"error\">$RegistrationError[3]</div>";
    }
    if (!isset(
$_POST['senderemail']) AND $_POST['senderemail'] == ""){
        
$error .= "<div class=\"error\">$RegistrationError[2]</div>";
    }
    if (!
$error){

        
$check mysql_query("SELECT picid from $pic_tbl where picid = '".valid_id($_POST['pid'])."'") Or die (mysql_error());
        
$row mysql_fetch_array($check);

        
$ReferEmail str_replace("{PHOTO}","<a href=\"$siteurl/?id={$row['picid']}\">{$siteurl}/?id={$row['picid']}</a>",$ReferEmail);
        
$ReferEmail str_replace("{SENDER}"$_POST['sendername'],$ReferEmail);
        
$ReferEmail str_replace("{PASSW}"$_POST['pass'],$ReferEmail);
        
        
$message "<html><head></head><body><br />";
        
$message .= $ReferEmail;
        
$message .= "<br /></body></html>";

        
$headers "From: {$_POST['sendername']} <{$_POST['senderemail']}>\r\nContent-type: text/html";

        
mail($_POST['email'], $ReferEmailSubject$message$headers);
        echo 
"<tr><td><div class=\"txt_dbrown_bold02\" align=\"center\">$ReferSuccess</div></td></tr></table></td>";
        include(
"templates/newheader_end.html");
    } else {
        include(
"templates/referform.html.php");
    }
} else  {
        include(
"templates/referform.html.php");
}
include(
"templates/footer.html.php");
?> 
the above is the whole page for refer.php

Thanks again

Last edited by nico_swd; 07-05-06 at 10:06 AM. Reason: Changer quote wrappers to php wrappers.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 07-04-06, 07:45 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
I don't see anything either. However, unless some lines are missing form the start of the post, line 44 is further down in the file than you indicate -
PHP Code:

} else {

echo 
"<tr><td><div style=\"padding:10px; text-align:center\" class=\"txt_dbrown_bold02\">$RecommendToFriend</div></td></tr></table></td>\n";
include(
"templates/referform.html.php");
include(
"templates/footer.html.php");
exit;
// <--------------- this is line 44 in the code you posted ---------------

Since this is after an include, it is possible that the problem is due to contents of the include file.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 07-04-06, 08:54 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
Actually, I found it by using the PHP code highlighting -
PHP Code:

$headers "From: {$_POST['sendername']} <{$from_address']}>\r\nContent-type: text/html"; 

The $from_address item has some problem. If there is a variable by that name, then the single-quote and closing bracket is where the problem is.

If you would have posted this using the PHP /PHP code wrappers instead of the QUOTE /QUOTE wrappers, the location of this problem would have stood out as the color change would not have changed back.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 07-05-06, 09:57 AM
unlisted80's Avatar
unlisted80 unlisted80 is offline
Newbie Coder
 
Join Date: Feb 2005
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
still didn't work...

This is my actual line of 44
Quote:
mail($_POST['email'], $ReferEmailSubject, $message, $headers);
and when i ran the script it's give me this problem
Quote:
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting '}' in /homepages/44/d147905660/htdocs/myfoldername/refer.php on line 44
so i am thinking the server didn't find myfoldername are. For example is work like this www.mydomain/refer.php Instead www.mydomain.com/myfoldername/refer.php. In this case i don't need my foldername
Quote:
include_once("$full_path_to_public_program/session.php");
Thanks once again
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 07-05-06, 10:12 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
There are two erros. One is the one that Mab mentioned.

Change this
PHP Code:

 $headers "From: {$_POST['sendername']} <{$from_address']}>\r\nContent-type: text/html"; 

To this

PHP Code:

 $headers "From: {$_POST['sendername']} <{$from_address}>\r\nContent-type: text/html"

And then do you have an unescaped quote in line 52.

Change
PHP Code:

$error .="<div class="error\">$RegistrationError[2]</div>"
To
PHP Code:

$error .="<div class=\"error\">$RegistrationError[2]</div>"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 07-05-06, 12:12 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
I ran the code, commenting out the include/require, mysql function calls, and code with user function calls, and supplied some values for the if tests... and I don't receive the error. This would indicate that it must be coming from a line I commented out or from something in one of the include/require files.

Here is the modified code to just past the mail(...) function call -
PHP Code:

<?php

error_reporting
(E_ALL); // error reporting I set
session_start();
// require("config.php");
// include_once("$full_path_to_public_program/session.php");

// include("templates/main.html.php");
// include("templates/leftside.html.php");
// include("templates/refer_header.html");
$_POST['send'] = "1"// value I set
if (isset($_POST['send']) AND $_POST['send'] == "1"){
//    if (!preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+@([-0-9A-Z]+\.)+([0-9A-Z]){2,4}$/i', EscapeString($_POST['email']))) {
//        $error .="<div class=\"error\">$RegistrationError[2]</div>";
//    }
$_POST['sendername'] = "sender"// value I set
if (!isset($_POST['sendername']) AND $_POST['sendername'] == ""){
$error .= "<div class=\"error\">$RegistrationError[3]</div>";
}
if (!
$error){
$_POST['senderemail'] = $_POST['sendername'];
// $check = mysql_query("SELECT picid from $pic_tbl where picid = '".valid_id($_POST['pid'])."'") Or die (mysql_error());
// $row = mysql_fetch_array($check);

$ReferEmail str_replace("{SENDER}"$_POST['sendername'],$ReferEmail);
//$ReferEmail = str_replace("{PASSW}", $_POST['pass'],$ReferEmail); // this line was already commented out.
$ReferEmail str_replace("{PHOTO}","<a href=\"$siteurl/?id={$row['picid']}\">{$siteurl}/?id={$row['picid']}</a>",$ReferEmail);

$message "<html><head></head><body><br />";
$message .= $ReferEmail;
$message .= "<br /></body></html>";

$headers "From: {$_POST['sendername']} <{$from_address}>\r\nContent-type: text/html";

 
mail($_POST['email'], $ReferEmailSubject$message$headers);

echo 
"<tr><td><div class=\"txt_dbrown_bold02\" align=\"center\">$ReferSuccess</div></td></tr></table></td>";
// include("templates/newheader_end.html");
// include("templates/footer.html.php");
exit;

} else {
echo 
"<tr><td><div style=\"padding:10px; text-align:center\" class=\"txt_dbrown_bold02\">$RecommendToFriend</div></td></tr></table></td>\n";
// include("templates/referform.html.php");
// include("templates/footer.html.php");
exit;
}
}
Edit: I also recommend echoing the contents of the variables, at least - $_POST['email'], $ReferEmailSubject, $message, and $headers to make sure they contain the expected contents.

Edit2: To send HTML email, in addition to the content type, your $header string needs a MIME version and a charset item.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???

Last edited by mab; 07-05-06 at 12:35 PM. Reason: Additional troubleshooting
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 07-05-06, 05:28 PM
unlisted80's Avatar
unlisted80 unlisted80 is offline
Newbie Coder
 
Join Date: Feb 2005
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by nico_swd
There are two erros. One is the one that Mab mentioned.

Change this
PHP Code:

 $headers "From: {$_POST['sendername']} <{$from_address']}>\r\nContent-type: text/html"; 

To this

PHP Code:

 $headers "From: {$_POST['sendername']} <{$from_address}>\r\nContent-type: text/html"

And then do you have an unescaped quote in line 52.

Change
PHP Code:

$error .="<div class="error\">$RegistrationError[2]</div>"
To
PHP Code:

$error .="<div class=\"error\">$RegistrationError[2]</div>"

This work fine...

Many Thanks for all your help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRIN aprogrammer PHP 20 08-31-11 06:56 AM
Parse error: parse error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' HELP stormshadow PHP 2 06-27-06 10:27 AM
Parse error: parse error, unexpected $ in... keefermedia PHP 4 04-23-06 12:21 PM
Parse error: parse error, unexpected T_VARIABLE aussietogo PHP 4 08-16-05 09:14 PM
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE | help? culticka PHP 1 11-25-04 04:10 PM


All times are GMT -5. The time now is 10:53 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.