DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   PHP (http://www.daniweb.com/forums/forum17.html)
-   -   Parse error: syntax error, unexpected T_STRING (http://www.daniweb.com/forums/thread167788.html)

CasTex Jan 11th, 2009 11:29 pm
Parse error: syntax error, unexpected T_STRING
 
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>";

almostbob Jan 11th, 2009 11:55 pm
Re: Parse error: syntax error, unexpected T_STRING
 
Quote:

Originally Posted by CasTex (Post 776208)
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>";

concatenation
$content .= "code";
$content .= "code";
$content .= "code";
Creates one logical line,
missing semi-colon after </issued>" creates a second line, and a syntax error

CasTex Jan 12th, 2009 1:20 am
Re: Parse error: syntax error, unexpected T_STRING
 
Ok, I use this;

$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>";

But now it gives error at the first line of this code...

kkeith29 Jan 12th, 2009 1:45 am
Re: Parse error: syntax error, unexpected T_STRING
 
i tried this:
      $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>";
and there were no errors on my server.

CasTex Jan 12th, 2009 2:09 am
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;

?>

kkeith29 Jan 12th, 2009 2:18 am
Re: Parse error: syntax error, unexpected T_STRING
 
you are missing a quotation on this line:

$your_password="xxx;  // change this to your blogger login password

rudevils Jan 12th, 2009 4:00 am
Re: Parse error: syntax error, unexpected T_STRING
 
You must change your code on line 25 like this:

$content = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>";

almostbob Jan 12th, 2009 8:12 am
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.


All times are GMT -4. The time now is 3:40 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC