The450Man Posted February 4, 2011 Share Posted February 4, 2011 I keep getting this error when trying to execute a script: Parse error: syntax error, unexpected $end in mydomain.com/myfolder/script.php on line 35 Here is the script: <?function wpPostXMLRPC($title,$body,$rpcurl,$username,$password,$category,$keywords='',$encoding='UTF-8') { $title = htmlentities($title,ENT_NOQUOTES,$encoding); $keywords = htmlentities($keywords,ENT_NOQUOTES,$encoding); $content = array( 'title'=>$title, 'description'=>$body, 'mt_allow_comments'=>0, // 1 to allow comments 'mt_allow_pings'=>0, // 1 to allow trackbacks 'post_type'=>'post', 'mt_keywords'=>$keywords, 'categories'=>array($category) ); $params = array(0,$username,$password,$content,true); $request = xmlrpc_encode_request('metaWeblog.newPost',$params); $ch = curl_init(); curl_setopt($ch, CURLOPT_POSTFIELDS, $request); curl_setopt($ch, CURLOPT_URL, $rpcurl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 1); $results = curl_exec($ch); curl_close($ch); return $results; $title="Lorem ipsum"; $body="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vestibulum pharetra mi quis rhoncus. Mauris lacinia neque id lacus lobortis a dictum augue molestie. Proin ut elit velit, in faucibus neque. Aliquam libero odio, bibendum non tempor eu, sodales vel felis."; $rpcurl="http://your_wordpress_blog_url/xmlrpc.php"; $username="Wordpress admin username here"; $password="Wordpress admin password here"; $categories="category name here"; echo wpPostXMLRPC($title,$body,$rpcurl,$username,$password,$categories,''); ?> It posts to my wordpress blog via php. I have been trying to solve it but have not had any luck. Link to comment https://forums.phpfreaks.com/topic/226732-parse-error-syntax-error-unexpected-end-in/ Share on other sites More sharing options...
Pikachu2000 Posted February 4, 2011 Share Posted February 4, 2011 Typically, that error indicates a missing closing curly } brace. Link to comment https://forums.phpfreaks.com/topic/226732-parse-error-syntax-error-unexpected-end-in/#findComment-1170049 Share on other sites More sharing options...
The450Man Posted February 5, 2011 Author Share Posted February 5, 2011 agreed. I cant seem to pin on where the error is. Link to comment https://forums.phpfreaks.com/topic/226732-parse-error-syntax-error-unexpected-end-in/#findComment-1170112 Share on other sites More sharing options...
kenrbnsn Posted February 5, 2011 Share Posted February 5, 2011 You never close the function with a "}" Ken Link to comment https://forums.phpfreaks.com/topic/226732-parse-error-syntax-error-unexpected-end-in/#findComment-1170140 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.