SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 37
  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2008
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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**** 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 Code:
    <?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’$contentfalse)) {
            die(
    'An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage());
        }
        echo 
    $client->getResponse();    //with Wordpress, will report the ID of the new post
    ?>

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2012
    Posts
    99
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    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 Code:

    <?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’$contentfalse)) { 
            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
    PHP Code:
    'categories'=>array($categories
    it should be this
    PHP Code:
    'categories'=>array($categories
    and then to finish off the array you would do this
    PHP Code:
    ); 
    .


    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 Code:

    <?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’$contentfalse)) { 
            die(
    'An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage()); 
        } 
        echo 
    $client->getResponse();    //with Wordpress, will report the ID of the new post 
    ?>

  3. #3
    SitePoint Evangelist
    Join Date
    Mar 2008
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Cmarenburg thanks for the reply, I tried it and I get An error occurred - -32700**** 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

  4. #4
    SitePoint Enthusiast
    Join Date
    Apr 2012
    Posts
    99
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    What line? Maybe some else can catch something i am not seeing.

  5. #5
    SitePoint Evangelist
    Join Date
    Mar 2008
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It doesn't say where unfortunately, I am using the code from this article
    http://life.mysiteonline.org/archive...d-XML-RPC.html

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,140
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    My guess is the die() is killing the script before all the closing tags are output.

    Can you temporarily change die to echo?

  7. #7
    SitePoint Member
    Join Date
    Aug 2012
    Location
    israel
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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)) {

  8. #8
    SitePoint Evangelist
    Join Date
    Mar 2008
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by canabatz View Post
    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

  9. #9
    SitePoint Evangelist
    Join Date
    Mar 2008
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

    Quote Originally Posted by Mittineague View Post
    My guess is the die() is killing the script before all the closing tags are output.

    Can you temporarily change die to echo?

  10. #10
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,140
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    Are you getting HTML in view-source? If so, try copying it into the W3C validator.

  11. #11
    SitePoint Evangelist
    Join Date
    Mar 2008
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague View Post
    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

  12. #12
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,118
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Can you show us your updated code and identify which command is giving the error? Is it the command for getCategories or newPost?

  13. #13
    SitePoint Evangelist
    Join Date
    Mar 2008
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    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->query('wp.getCategories','WHERE-I-PUT-MY-WORDPRESS-PASSWORD', 'WHERE-I-PUT-MY-WORDPRESS-USERNAME',’password’)) {
    echo('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','WHERE-I-PUT-MY-WORDPRESS-PASSWORD', 'WHERE-I-PUT-MY-WORDPRESS-USERNAME',’password’, $content, false)) {
    echo('An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage());
    }
    echo $client->getResponse(); //with Wordpress, will report the ID of the new post
    ?>

  14. #14
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,118
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    To help identify which line is causing the error, try changing your code to the following:
    PHP 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-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'$contentfalse)) { 
    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.
    Last edited by cpradio; Aug 13, 2012 at 11:41. Reason: Fixed encoding issue with 'password'

  15. #15
    SitePoint Evangelist
    Join Date
    Mar 2008
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  16. #16
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,118
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Okay, to get past that error try this code
    PHP 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'$contentfalse)) {  
    echo(
    'An error occurred calling metaWeblog.newPost - '.$client->getErrorCode().":".$client->getErrorMessage());  
    }  
    echo 
    $client->getResponse(); //with Wordpress, will report the ID of the new post  
    ?>

  17. #17
    SitePoint Evangelist
    Join Date
    Mar 2008
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks cpradio , I now get:

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

  18. #18
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,118
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    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 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)  
    );  

    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'$contentfalse)) {  
    echo(
    'An error occurred calling metaWeblog.newPost - '.$client->getErrorCode().":".$client->getErrorMessage());  
    }  
    echo 
    $client->getResponse(); //with Wordpress, will report the ID of the new post  
    ?>

  19. #19
    SitePoint Evangelist
    Join Date
    Mar 2008
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  20. #20
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,118
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    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?

  21. #21
    SitePoint Evangelist
    Join Date
    Mar 2008
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi cp well really I'm just following the tutorial, it says:

    "The script can be placed on any PHP enabled server, so long as it is given a PHP file extension (so the server knows to run it as PHP). The URL must point to your Wordpress installation's proper path, as explained in the article. The username and password fields must be changed to match your Wordpress username and password. The include path must point to a version of the Wordpress class-IXR.php file, so if not on the same server/account as the Wordpress installation, then you may need to download a copy of that file to include it."


    So I thought it came out of the box as such, but obviously I'll have to provide those details in a form or something I imagine

  22. #22
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,118
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Well, it depends on how you want to post to your wordpress site. Do you have a thought in mind? What is the overall plan for using this?

  23. #23
    SitePoint Evangelist
    Join Date
    Mar 2008
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, I just want a page where I can enter the title etc and hit send and post to my site

  24. #24
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,118
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Okay, so yes, you will want to create a HTML page that has a form with a field named title, and a field named description. That form should post to your php script. Once you have your form built, post the HTML and your PHP here again and we can help you tie them together.

  25. #25
    SitePoint Evangelist
    Join Date
    Mar 2008
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks cpradio, here's the form:


    <style>
    #form {width: 360px; background-color: #ccc;
    border: 1px dotted #333; padding: 5px;
    margin: 0px auto;}
    div.row {
    clear: both;
    padding-top: 5px;
    }

    div.row span.label {
    float: left;
    width: 100px;
    text-align: right;
    }

    div.row span.formw {
    float: right;
    width: 235px;
    text-align: left;
    }
    </style>

    <div id="form">
    <form name="wordressposter" action="" method="post">
    <div class="row">
    <span class="label">Title: </span><span
    class="formw"><input name="title" type="text" size="25" /></span>
    </div>
    <div class="row">
    <span class="label">Comments: </span><span class="formw">
    <textarea cols="25" rows="8" name="article"></textarea>
    </span>
    </div>
    <div class="row">
    <span class="label">Tags: </span><span
    class="formw"><input name="title" type="text" size="25" name="keywords"/></span>
    </div>
    <div class="row">
    <span class="label">Categories: </span><span
    class="formw"><input name="title" type="text" size="25" name="categories"/></span>
    </div>

    <div class="spacer">
    </div>
    </form>
    </div>
    Last edited by Bayliss Trevor; Aug 13, 2012 at 17:02. Reason: Put spaces in was creating emoticons


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •