Jump to content

blunt

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

About blunt

  • Birthday 01/15/1984

Contact Methods

  • Website URL
    http://www.freewarebeast.com/

Profile Information

  • Gender
    Male
  • Location
    Cape Town, S.Africa

blunt's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. is your error reporting set to E_ALL ?
  2. Hi, I do my own pagination its really quite easy. [code] // im not including much error checking this is just the basics - assuming mysql queries return results etc. // fetch the total amount of results to work out number of pages - you could store the total pages in // a session variable but im not going to bring sessions into this example $sql = 'select col1, col2, col3 from table'; $res = mysql_query($sql); $total_results = mysql_num_rows($res); $total_per_page = 10; // work out the number of pages, use ceil incase its not an equal divide // need an extra page to show remaining results $number_of_pages = ceil($total_results / $total_per_page); // check if we have the get variable "page" indicating what page we are on // otherwise just set it to page 1 if (isset($_GET['page']) && is_numeric($_GET['page']) && $_GET['page'] <= $number_of_pages)     $page = $_GET['page']; else     $page = 1; // construct the page links $pagelinks = 'Page(s): '; for ($x = 1; $x <= $number_of_pages; $x++) {     if ($x == $page) $pagelinks .= '<b>'.$x.'</b>&nbsp;';     else $pagelinks .= '<a href="'.$_SERVER['PHP_SELF'].'?page='.$x.'">'.$x.'</a>&nbsp;'; } if ($page > 1) $previouslink = '<a href="'.$_SERVER['PHP_SELF'].'?page='.($page-1).'">&laquo; Previous</a>'; else $previouslink = ''; if ($page < $number_of_pages) $nextlink = '<a href="'.$_SERVER['PHP_SELF'].'?page='.($page+1).'">Next &raquo;</a>'; else $nextlink = ''; // find the starting record number $start_record = (($total_per_page * $page) - $total_per_page); // now we modify our original sql statement to return only the results we are displaying $sql .= ' limit '.$start_record.', '.$total_per_page; // re-execute $res = mysql_query($sql); while ($row = mysql_fetch_object($res)) {   echo '<div id="result">'.$row->col1.' - '.$row->col2.' - '.$row->col3.'</div>'."\n"; } echo '<div id="pageNav">'.$previouslink; if ($nextlink != '') echo ' - '; echo $nextlink.'<br/>'.$pagelinks.'</div>'."\n"; [/code] I wrote this out of my head now so there may be a syntax error or two but thats how I do my simple pagination...
  3. yes as long as the user set up on the MySQL server is configured for access from the different host.
  4. Hello, I am having a problem using CURL to query a JSON-RPC server, If I do the following using CURL via commandline: [quote] -bash-2.05b$ curl --data-binary '{"method": "push", "value": "hello"}' -H 'content-type: text/plain;'  http://192.168.5.37:8080/json "OK"-bash-2.05b$ -bash-2.05b$ curl --data-binary '{"method": "pop"}' -H 'content-type: text/plain;'  http://192.168.5.37:8080/json "hello"-bash-2.05b$ [/quote] This executes successfully as you can see, now I have the following PHP Code: [code] <?php // setup json data $url = "http://192.168.5.37:8080/json"; $post_data = array('method' => 'push', 'value' => 'testing'); $post_data = json_encode($post_data); echo $post_data.'<br/>'; // execute json request $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER, 'content-type: text/plain;'); curl_setopt($ch, CURLOPT_TRANSFERTEXT, 0); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // decode result if ($result = @curl_exec($ch)) { echo 'query success<br/><pre>'; print_r(json_decode($result)); echo '</pre>'; } else { 'query failed'; } curl_close($ch); ?> [/code] Script outputs the following: [quote] {"method":"push","value":"testing"} query success stdClass Object (     [response] => stdClass Object         (             [error] => Unkown method, list of known methods: ['push', 'pop']         ) ) [/quote] Is there anything here I am doing wrong, I have set it to post the data using plaintext in the correct json format... something I'm missing here?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.