Parse error , unexpected ';'

Hi all
I am getting this error: Parse error: syntax error, unexpected ‘;’, expecting ‘)’ on line 14

I originally got this error:
An error occurred - -32700:parse error. not well formed
so I changed the code to an array but php is not my strong point and I get the error. Why am I getting this error? Thanks

<?php
	include("./wp-includes/class-IXR.php");
	$client = new IXR_Client('http://mysite.com/xmlrpc.php');

	if (!$client->query('wp.getCategories','password', 'username',’password’)) {
		die('An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage());
	}
	$response = $client->getResponse();




$content = array(
 'title'=>$title;
 'description'=>$article;
 'mt_allow_comments'=>$allowcomments;
 'mt_allow_pings'=>$allowtrackbacks;
 'post_type'=>'post';
 'mt_keywords'=>$keywords;
 'categories'=>array($categories;



	if (!$client->query('metaWeblog.newPost','password', 'username',’password’, $content, false)) {
		die('An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage());
	}
	echo $client->getResponse();    //with Wordpress, will report the ID of the new post
?>




	
	

Hey there,

You are getting the ‘unexpected ;’ error message because you are using a semi-colon ; to end the lines of the arrays (lines 14-20).



<?php
    include("./wp-includes/class-IXR.php");
    $client = new IXR_Client('http://mysite.com/xmlrpc.php');

    if (!$client->query('wp.getCategories','password', 'username',’password’)) {
        die('An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage());
    }
    $response = $client->getResponse();




$content = array(
 'title'=>$title;
 'description'=>$article;
 'mt_allow_comments'=>$allowcomments;
 'mt_allow_pings'=>$allowtrackbacks;
 'post_type'=>'post';
 'mt_keywords'=>$keywords;
 'categories'=>array($categories;



    if (!$client->query('metaWeblog.newPost','password', 'username',’password’, $content, false)) {
        die('An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage());
    }
    echo $client->getResponse();    //with Wordpress, will report the ID of the new post
?>

how ever you should be using a comma. As well you forgot to close the arrays. Take for example

'categories'=>array($categories; 

it should be this

'categories'=>array($categories)

and then to finish off the array you would do this

);

.

Try this. (only line that might be wrong, not an excerpt with arrays) is line 20. Some one want to check that it is correct?



<?php
    include("./wp-includes/class-IXR.php");
    $client = new IXR_Client('http://mysite.com/xmlrpc.php');

    if (!$client->query('wp.getCategories','password', 'username',’password’)) {
        die('An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage());
    }
    $response = $client->getResponse();




$content = array(
 'title'=>$title,
 'description'=>$article,
 'mt_allow_comments'=>$allowcomments,
 'mt_allow_pings'=>$allowtrackbacks,
 'post_type'=>'post',
 'mt_keywords'=>$keywords,
 'categories'=>array($categories)
 );



    if (!$client->query('metaWeblog.newPost','password', 'username',’password’, $content, false)) {
        die('An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage());
    }
    echo $client->getResponse();    //with Wordpress, will report the ID of the new post
?>

Hi Cmarenburg thanks for the reply, I tried it and I get An error occurred - -32700:parse error. not well formed

FYI in these parts:

‘metaWeblog.newPost’,‘password’, ‘username’,’password’,

I put in the first password my wordpress password and in username my wordpress username and in the last password left it as password.
Cheers

What line? Maybe some else can catch something i am not seeing.

It doesn’t say where unfortunately, I am using the code from this article
http://life.mysiteonline.org/archives/161-Automatic-Post-Creation-with-Wordpress,-PHP,-and-XML-RPC.html

My guess is the die() is killing the script before all the closing tags are output.

Can you temporarily change die to echo?

change this line:

if (!$client->query(‘metaWeblog.newPost’,‘password’, ‘username’,’password’, $content, false)) {

to this:

if (!$client->query(‘metaWeblog.newPost’,‘password’, ‘username’,‘password’, $content, false)) {

Hi Canabatz I see no difference between those two lines

Hi Mittineague
Thanks for the reply, I just did that and get this error:

An error occurred - -32700: parse error. not well formedAn error occurred - -32700: parse error. not well formedArray

Are you getting HTML in view-source? If so, try copying it into the W3C validator.

No I’m not getting HTML in view-source

Can you show us your updated code and identify which command is giving the error? Is it the command for getCategories or newPost?

Sure, here is the updated code, as far as which command gives me the error I don’t get any specific line for the errror:

<?php
include(“./wp-includes/class-IXR.php”);
$client = new IXR_Client(‘http://MYSITE.org/xmlrpc.php’);

if (!$client-&gt;query('wp.getCategories','WHERE-I-PUT-MY-WORDPRESS-PASSWORD', 'WHERE-I-PUT-MY-WORDPRESS-USERNAME',’password’)) { 
     echo('An error occurred - '.$client-&gt;getErrorCode().":".$client-&gt;getErrorMessage()); 
 }  
$response = $client-&gt;getResponse();  

$content = array(
‘title’=>$title,
‘description’=>$article,
‘mt_allow_comments’=>$allowcomments,
‘mt_allow_pings’=>$allowtrackbacks,
‘post_type’=>‘post’,
‘mt_keywords’=>$keywords,
‘categories’=>array($categories)
);

if (!$client-&gt;query('metaWeblog.newPost','WHERE-I-PUT-MY-WORDPRESS-PASSWORD', 'WHERE-I-PUT-MY-WORDPRESS-USERNAME',’password’, $content, false)) { 
     echo('An error occurred - '.$client-&gt;getErrorCode().":".$client-&gt;getErrorMessage()); 
 }  
echo $client-&gt;getResponse();    //with Wordpress, will report the ID of the new post 

?>

To help identify which line is causing the error, try changing your code to the following:

<?php
include("./wp-includes/class-IXR.php");
$client = new IXR_Client('http://MYSITE.org/xmlrpc.php');

if (!$client->query('wp.getCategories','WHERE-I-PUT-MY-WORDPRESS-PASSWORD', 'WHERE-I-PUT-MY-WORDPRESS-USERNAME','password')) {
echo('An error occurred calling wp.getCategories - '.$client->getErrorCode().":".$client->getErrorMessage());
}
$response = $client->getResponse();




$content = array(
'title'=>$title,
'description'=>$article,
'mt_allow_comments'=>$allowcomments,
'mt_allow_pings'=>$allowtrackbacks,
'post_type'=>'post',
'mt_keywords'=>$keywords,
'categories'=>array($categories)
);



if (!$client->query('metaWeblog.newPost','WHERE-I-PUT-MY-WORDPRESS-PASSWORD', 'WHERE-I-PUT-MY-WORDPRESS-USERNAME','password', $content, false)) {
echo('An error occurred calling metaWeblog.newPost - '.$client->getErrorCode().":".$client->getErrorMessage());
}
echo $client->getResponse(); //with Wordpress, will report the ID of the new post
?>

Then copy the error to us again, so we can see which one it was calling.

Hi thanks, I get this error which seems to be my login details, I obviously have them in the wrong order or something

An error occurred calling wp.getCategories - 403:Bad login/pass combination.An error occurred calling metaWeblog.newPost - 403:Bad login/pass combination.Array

Okay, to get past that error try this code

<?php  
include("./wp-includes/class-IXR.php");  
$client = new IXR_Client('http://MYSITE.org/xmlrpc.php');  

if (!$client->query('wp.getCategories','', 'WHERE-I-PUT-MY-WORDPRESS-USERNAME','WHERE-I-PUT-MY-WORDPRESS-PASSWORD')) {  
echo('An error occurred calling wp.getCategories - '.$client->getErrorCode().":".$client->getErrorMessage());  
}  
$response = $client->getResponse();  




$content = array(  
'title'=>$title,  
'description'=>$article,  
'mt_allow_comments'=>$allowcomments,  
'mt_allow_pings'=>$allowtrackbacks,  
'post_type'=>'post',  
'mt_keywords'=>$keywords,  
'categories'=>array($categories)  
);  



if (!$client->query('metaWeblog.newPost','', 'WHERE-I-PUT-MY-WORDPRESS-USERNAME','WHERE-I-PUT-MY-WORDPRESS-PASSWORD', $content, false)) {  
echo('An error occurred calling metaWeblog.newPost - '.$client->getErrorCode().":".$client->getErrorMessage());  
}  
echo $client->getResponse(); //with Wordpress, will report the ID of the new post  
?>

Thanks cpradio , I now get:

An error occurred calling metaWeblog.newPost - 500:Content, title, and excerpt are empty.Array

Okay, this time we need to see what you are sending to the API, so I added a var_dump for $content, when you get the output, paste it back here we know what it showed.

<?php  
include("./wp-includes/class-IXR.php");  
$client = new IXR_Client('http://MYSITE.org/xmlrpc.php');  

if (!$client->query('wp.getCategories','', 'WHERE-I-PUT-MY-WORDPRESS-USERNAME','WHERE-I-PUT-MY-WORDPRESS-PASSWORD')) {  
echo('An error occurred calling wp.getCategories - '.$client->getErrorCode().":".$client->getErrorMessage());  
}  
$response = $client->getResponse();  




$content = array(  
'title'=>$title,  
'description'=>$article,  
'mt_allow_comments'=>$allowcomments,  
'mt_allow_pings'=>$allowtrackbacks,  
'post_type'=>'post',  
'mt_keywords'=>$keywords,  
'categories'=>array($categories)  
);  

var_dump($content); // paste the output of this back to the forum for us to review.

if (!$client->query('metaWeblog.newPost','', 'WHERE-I-PUT-MY-WORDPRESS-USERNAME','WHERE-I-PUT-MY-WORDPRESS-PASSWORD', $content, false)) {  
echo('An error occurred calling metaWeblog.newPost - '.$client->getErrorCode().":".$client->getErrorMessage());  
}  
echo $client->getResponse(); //with Wordpress, will report the ID of the new post  
?>

Thanks again cpradio

An error occurred calling wp.getCategories - 403:Bad login/pass combination.array(7) { [“title”]=> NULL [“description”]=> NULL [“mt_allow_comments”]=> NULL [“mt_allow_pings”]=> NULL [“post_type”]=> string(4) “post” [“mt_keywords”]=> NULL [“categories”]=> array(1) { [0]=> NULL } } An error occurred calling metaWeblog.newPost - 500:Content, title, and excerpt are empty.Array

Okay, how are you setting $title, $article, $allowcomments, $allowtrackbacks, $keywords, $categories? As none of those have values, are you just doing a proof of concept with the thought of then replacing your test data with the real information?