943,635 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 3076
  • PHP RSS
Jan 11th, 2009
0

Parse error: syntax error, unexpected T_STRING

Expand Post »
I am getting error at the second line of the code, what is the problem

$content = '<' . '?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?' . '>';
$content .= "<entry xmlns='http://purl.org/atom/ns#'>";
$content .= "<title mode='escaped' type='text/plain'>".$title."</title>";
$content .= "<issued>".$issued."</issued>"
$content .= "<generator url='http://www.yoursitesurlhere.com'>client's name</generator>";
$content .= "<content type='application/xhtml+xml'>";
$content .= "<div xmlns='http://www.w3.org/1999/xhtml'>".$body."</div>";
$content .= "</content>";
$content .= "</entry>";
Reputation Points: 3
Solved Threads: 0
Light Poster
CasTex is offline Offline
45 posts
since Mar 2008
Jan 11th, 2009
0

Re: Parse error: syntax error, unexpected T_STRING

Click to Expand / Collapse  Quote originally posted by CasTex ...
I am getting error at the second line of the code, what is the problem

php Syntax (Toggle Plain Text)
  1. $content = '<' . '?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?' . '>';
  2. $content .= "<entry xmlns='http://purl.org/atom/ns#'>";
  3. $content .= "<title mode='escaped' type='text/plain'>".$title."</title>";
  4. $content .= "<issued>".$issued."</issued>"
  5. $content .= "<generator url='http://www.yoursitesurlhere.com'>client's name</generator>";
  6. $content .= "<content type='application/xhtml+xml'>";
  7. $content .= "<div xmlns='http://www.w3.org/1999/xhtml'>".$body."</div>";
  8. $content .= "</content>";
  9. $content .= "</entry>";
concatenation
$content .= "code";
$content .= "code";
$content .= "code";
Creates one logical line,
missing semi-colon after </issued>" creates a second line, and a syntax error
Last edited by almostbob; Jan 11th, 2009 at 11:56 pm.
Reputation Points: 562
Solved Threads: 367
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009
Jan 12th, 2009
0

Re: Parse error: syntax error, unexpected T_STRING

Ok, I use this;

PHP Syntax (Toggle Plain Text)
  1. $content = '<' . '?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?' . '>';
  2. $content .= "<entry xmlns='http://purl.org/atom/ns#'>";
  3. $content .= "<title mode='escaped' type='text/plain'>".$title."</title>";
  4. $content .= "<issued>".$issued."</issued>";
  5. $content .= "<generator url='http://www.yoursitesurlhere.com'>client's name</generator>";
  6. $content .= "<content type='application/xhtml+xml'>";
  7. $content .= "<div xmlns='http://www.w3.org/1999/xhtml'>".$body."</div>";
  8. $content .= "</content>";
  9. $content .= "</entry>";

But now it gives error at the first line of this code...
Last edited by CasTex; Jan 12th, 2009 at 1:28 am.
Reputation Points: 3
Solved Threads: 0
Light Poster
CasTex is offline Offline
45 posts
since Mar 2008
Jan 12th, 2009
0

Re: Parse error: syntax error, unexpected T_STRING

i tried this:
PHP Syntax (Toggle Plain Text)
  1. $content = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>';
  2. $content .= "<entry xmlns='http://purl.org/atom/ns#'>";
  3. $content .= "<title mode='escaped' type='text/plain'>".$title."</title>";
  4. $content .= "<issued>".$issued."</issued>";
  5. $content .= "<generator url='http://www.yoursitesurlhere.com'>client's name</generator>";
  6. $content .= "<content type='application/xhtml+xml'>";
  7. $content .= "<div xmlns='http://www.w3.org/1999/xhtml'>".$body."</div>";
  8. $content .= "</content>";
  9. $content .= "</entry>";
and there were no errors on my server.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Jan 12th, 2009
0

Re: Parse error: syntax error, unexpected T_STRING

Really thanks, but now I get this error

Parse error: syntax error, unexpected T_DNUMBER at line 25

My full code is this

<?php
/*
Script by CasTex
*/

// post tarihi
$issued=gmdate("Y-m-d\TH:i:s\Z", time());

// post title kısmı
$title="bakalim oliyir mii";

// postun body kısmı
$body="yaz buraya bişiler ne bilim ben.";

// blogid sini yaz
$blog_id="7421378769979406050";

// kullanici adi ve parola
$your_username="xxx";  //change this to your blogger login username
$your_password="xxx;  // change this to your blogger login password

$soru = "?";

// bloga yollanacak xml data
      $content = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>';
      $content .= "<entry xmlns='http://purl.org/atom/ns#'>";
      $content .= "<title mode='escaped' type='text/plain'>".$title."</title>";
      $content .= "<issued>".$issued."</issued>";
      $content .= "<generator url='http://www.yoursitesurlhere.com'>client's name</generator>";
      $content .= "<content type='application/xhtml+xml'>";
      $content .= "<div xmlns='http://www.w3.org/1999/xhtml'>".$body."</div>";
      $content .= "</content>";
      $content .= "</entry>";

// bloga yollancak header
$headers  =  array( "Content-type: application/atom+xml" );

// Use curl to post to your blog.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.blogger.com/atom/".$blog_id);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_USERPWD, $your_username.':'.$your_password);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);

$data = curl_exec($ch);

if (curl_errno($ch)) {
 print curl_error($ch);
} else {
 curl_close($ch);
}

// sonucu bas
echo $data;

?>
Last edited by CasTex; Jan 12th, 2009 at 2:10 am.
Reputation Points: 3
Solved Threads: 0
Light Poster
CasTex is offline Offline
45 posts
since Mar 2008
Jan 12th, 2009
0

Re: Parse error: syntax error, unexpected T_STRING

you are missing a quotation on this line:

PHP Syntax (Toggle Plain Text)
  1. $your_password="xxx; // change this to your blogger login password
  2.  
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Jan 12th, 2009
0

Re: Parse error: syntax error, unexpected T_STRING

You must change your code on line 25 like this:

PHP Syntax (Toggle Plain Text)
  1. $content = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>";
Reputation Points: 10
Solved Threads: 10
Junior Poster in Training
rudevils is offline Offline
80 posts
since Jan 2008
Jan 12th, 2009
0

Re: Parse error: syntax error, unexpected T_STRING

My suggestion is to ditch whatever editor you are using, and set up an editor with code highlighting
the missing quotes, semicolons and other syntax errors would then be highlighted while you are editing.
Reputation Points: 562
Solved Threads: 367
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Online payment Help
Next Thread in PHP Forum Timeline: Shopping cart





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC