Current location: Hot Scripts Forums » Programming Languages » PHP » Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING o

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

Reply
  #1 (permalink)  
Old
Newbie Coder
 
Join Date: Jul 2007
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING o

Hey guys having some problems with a bit of code, if anyone can help out that would be excellent.

Error : Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampp\htdocs\sites\Project\adminmodsubown.php on line 75

PHP Code:

case "accept":


$validid set_validid();
$sql "SELECT mod_subowner.sub_id, subjects.subject, users.id AS userid, users.username, users.email FROM mod_subowner INNER JOIN subjects ON 
mod_subowner.sub_id = subjects.id LEFT JOIN users ON 
mod_subowner.user_id = users.id WHERE mod_subowner.id = " 
$validid ";";
$result mysql_query($sql);
$row mysql_fetch_assoc($result);
$numrows mysql_num_rows($result);

$mail_username $row['username'];
$main_email $row['email'];
$mail_subject $row['subject'];

$mail_body=<<<_MESSAGE_
Hi, $mail_username,I am pleased to inform you that you have been accepted as the new owner of the '$mail_subject' subject.When you next log into '$config_sitename' you will see the subject in your Control Panel.King Regards,$config_sitename Administrator _MESSAGE_;
mail(
$mail_email, "Ownership Request For " . $mail_subject . " accepted!", $mail_body);

$addsql = "UPDATE subjects SET owner_id = " . $row['userid'] . " WHERE id = " . $row['sub_id'] . ";";
mysql_query(
$addsql);

$delsql = "DELETE FROM mod_subowner WHERE sub_id = " . $row['sub_id'] . ";";
mysql_query(
$delsql);

header("Location: " . 
$config_basedir . "adminmodsubown.php?func=main");
break; 

Line 75 :
PHP Code:

$addsql "UPDATE subjects SET owner_id = " $row['userid'] . " WHERE id = " $row['sub_id'] . ";"
any ideas i have searched and searched but i cannot find the problem.
Reply With Quote

Featured Marketplace Scripts (view more)

  #2 (permalink)  
Old
Coding Addict
 
Join Date: Jun 2005
Location: Singapore
Posts: 377
Thanks: 0
Thanked 1 Time in 1 Post
Try this:

PHP Code:

$addsql "UPDATE subjects SET owner_id =".$row['userid']." WHERE id =".$row['sub_id']"; 

Reply With Quote
  #3 (permalink)  
Old
Newbie Coder
 
Join Date: Jul 2007
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Hey Nikas, comes back with same error, I will paste full page so you get more of an idea whats going on in the script.
PHP Code:

 <?php

session_start
();
if(!
$_SESSION['SESS_ADMINUSER']) {
header("Location: " $config_basedir);
}

require(
"db.php");
require(
"functions.php");

function 
set_validid() {
if(
pf_check_number($_GET['id']) == TRUE) {
return 
$_GET['id'];
}
else {
header("Location: " $config_basedir);
}
}
switch(
$_GET['func']) {

case 
"main":
require(
"header.php");
$subssql "SELECT subjects.subject, subjects.id FROM subjects INNER JOIN mod_subowner ON subjects.id = mod_subowner.sub_id
GROUP BY subject.id;"
;
$subsresult mysql_query($subssql);
$subsnumrows mysql_num_rows($subsresult);

echo 
"<h1>Subjects and Ownership</h1>";

if(
$subsnumrows == 0) {
echo 
"No requests have been made.";
}
else {
while(
$subrow mysql_fetch_assoc($subsresult)) {
$reqsql "SELECT users.id AS userid, users.username,
 mod_subowner.* FROM users INNER JOIN mod_subowner ON
    mod_subowner.user_id = users.id WHERE mod_subowner.sub_id = " 
$subsrow['id'] . ";";
    
$reqresult mysql_query($reqsql);
    
echo 
"<table class='visible' cellpadding=10 cellspacing=0>";
echo 
"<tr><th class'visible' colspan='4'> Ownership requests for <i>" $subrow['subject'] . "</i></th></tr>";
while(
$reqrow mysql_fetch_assoc($reqresult)) {
echo 
"<tr>";
echo 
"<td>Requeted By <strong>" $reqrow['username'] . "</strong></td>";
echo 
"<td>" $reqrow['reasons'] . "</td>";
echo 
"<td><a href='" $SCRIPT_NAME "?func=accept&id=" $reqrow['id'] . "'>Accept</a></td>";
echo 
"<td><a href='" $SCRIPT_NAME "?func=deny&id=" $reqrow['id'] . "'>Deny</a></td>";
echo 
"</tr>";
}

echo 
"</table>";
echo 
"<br />";
}
}
break;


case 
"accept":

$validid set_validid();
$sql "SELECT mod_subowner.sub_id, subjects.subject, users.id AS userid, users.username, users.email FROM mod_subowner INNER JOIN subjects ON 
mod_subowner.sub_id = subjects.id LEFT JOIN users ON 
mod_subowner.user_id = users.id WHERE mod_subowner.id = " 
$validid ";";
$result mysql_query($sql);
$row mysql_fetch_assoc($result);
$numrows mysql_num_rows($result);

$mail_username $row['username'];
$main_email $row['email'];
$mail_subject $row['subject'];

$mail_body=<<<_MESSAGE_
Hi, $mail_username,I am pleased to inform you that you have been accepted as the new owner of the '$mail_subject' subject.When you next log into '$config_sitename' you will see the subject in your Control Panel.King Regards,$config_sitename Administrator _MESSAGE_;
mail(
$mail_email, "Ownership Request For " . $mail_subject . " accepted!", $mail_body);

$addsql = "UPDATE subjects SET owner_id = " . $row['userid'] . " WHERE id = " . $row['sub_id'] . ";";
mysql_query(
$addsql);

$delsql = "DELETE FROM mod_subowner WHERE sub_id = " . $row['sub_id'] . ";";
mysql_query(
$delsql);

header("Location: " . 
$config_basedir . "adminmodsubown.php?func=main");
break;

case "deny":

$validid = set_validid();
require("header.php");
echo "<h1>Are you sure that you want to deny this request?</h1>";
echo "<p>[<a href='adminmodsubown.php?func=denyconf&id=" . 
$validid . "'>Yes</a>]
[<a href='adminmodsubown.php?func=main'>No</a>]";
break;

case "denyconf":
 
$validid = set_validid();
    
$sql = "SELECT mod_subowner.sub_id, subjects,subject, users.id AS userid, users.username, users.email FROM mod_subowner INNER JOIN
    subjects ON mod_subowner.sub_id = subjects.id LEFT JOIN users ON mod_subowner.user_id = users.id WHERE mod_subowner.id = " . 
$validid . ";";
    
$result = mysql_query($sql);
    
$row = mysql_fetch_assoc($result);
    
$numrows = mysql_num_rows($result);
    
    
$mail_username = $row['username'];
    
$mail_email = $row['email'];
    
$mail_subject = $row['subject'];
    
    
$mail_body=<<<_MESSAGE_
    Hi 
$mail_username,    I am writing to infom you that your request for ownership of the '$mail_subject' subject has been declined.    Better luck next time.    King Regards,    $config_sitename Administrator    _MESSAGE_;    
    mail(
$mail_email, "Ownership Request For " . $mail_subject . " Denied!", $mail_body);
    
    
$delsql = "DELETE FROM mod_subowner WHERE id = " . $validid . ";";
    mysql_query(
$delsql);
    
    header("Location: " . 
$config_basedir . "adminmodsubown.php?func=main");
    break;
    
}
    require("footer.php");
?>
Reply With Quote
  #4 (permalink)  
Old
Coding Addict
 
Join Date: Jun 2005
Location: Singapore
Posts: 377
Thanks: 0
Thanked 1 Time in 1 Post
Sorry, I missed out a " at the end.

Try this and see how it goes. Meanwhile, I try to look for other problem.

PHP Code:

$addsql "UPDATE subjects SET owner_id =".$row['userid']." WHERE id =".$row['sub_id']""
Reply With Quote
  #5 (permalink)  
Old
Newbie Coder
 
Join Date: Jul 2007
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Its cool,
tried that code same error i think its to do with the mail function
$mail_body=<<<_MESSAGE , I could be wrong tho i had spaces and i closed them all off and then it started displayed that new error! if that helps any
thanks
Reply With Quote
  #6 (permalink)  
Old
Coding Addict
 
Join Date: Jun 2005
Location: Singapore
Posts: 377
Thanks: 0
Thanked 1 Time in 1 Post
Seem like it's the quote problem.

PHP Code:

$addsql "UPDATE subjects SET owner_id=$row['userid'] WHERE id=$row['sub_id']"
Reply With Quote
  #7 (permalink)  
Old
Newbie Coder
 
Join Date: Jul 2007
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Tried that also nikas also doesnt work, Iam really stump'd i have been looking at this code for the past 2 hours and not getting anywhere fast!
Reply With Quote
  #8 (permalink)  
Old
Coding Addict
 
Join Date: Jun 2005
Location: Singapore
Posts: 377
Thanks: 0
Thanked 1 Time in 1 Post
For HereDoc Synatax,

You need to close the message when you have come to an end.

For example,
PHP Code:

$message = <<<_message_ // start of HereDoc
some some content
_message_
// indicate end of HereDoc 
I'm not sure where you want to close yours, so try it and see how is it.
Reply With Quote
  #9 (permalink)  
Old
Newbie Coder
 
Join Date: Jul 2007
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:

$mail_body=<<<_MESSAGE_ 

Hi
$mail_username,I am pleased to inform you that you have been accepted as the new owner of the '$mail_subject' subject.When you next log into '$config_sitename' you will see the subject in your Control Panel.King Regards,$config_sitename Administrator _MESSAGE_
its at end of text do you think it needs to be on a new line?
Reply With Quote
  #10 (permalink)  
Old
Coding Addict
 
Join Date: Jun 2005
Location: Singapore
Posts: 377
Thanks: 0
Thanked 1 Time in 1 Post
Yes, it need to be on a new line, else it won't works.

You may also want to change back your SQL statement to see if it works as it should be.
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 21 06-06-12 11:02 PM
Parse error: syntax error, unexpected ';', expecting T_OLD_FUNCTION or T_FUNCTION or Dr. Forensics PHP 3 09-13-06 06:21 AM
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' Dr. Forensics PHP 3 07-15-06 03:54 PM
parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting '}' unlisted80 PHP 8 07-05-06 04:28 PM
Parse error: parse error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' HELP stormshadow PHP 2 06-27-06 09:27 AM


All times are GMT -5. The time now is 11:24 PM.
vBulletin® Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.