0

The following code works fine on local server but on online server throws HTTP ERROR 500. cURL is also enable. Have checked the error log it say;

AH01071: Got error 'PHP message: PHP Fatal error: Uncaught exception 'Pph\ApiClientException' with message 'Unknown error HTTP/1.1 400 BAD REQUEST\r\nSe

$tcom = $ApiClient->apiCall('get', 'companies');
echo "<table>"; 
foreach($tcom as $key=>$value){

  foreach($value as $k => $v){
    echo'<tr>';
    echo '<td>'  . $k . '</td>';
    echo '<td>'  . $v . '</td>';
    echo '</tr>';
  }
}
echo "</table>";
jwvh
  • 50,871
  • 7
  • 38
  • 64
Taslim
  • 33
  • 9
  • can you check value of `$tcom` on your server url ? use `print_r($tcom);exit;` – Niklesh Raut Jul 23 '16 at 11:37
  • Also just ensure about database credentials too. – Niklesh Raut Jul 23 '16 at 11:38
  • Why it only works on local server? What has to be done here? – Taslim Jul 23 '16 at 11:41
  • Have you changed DB credentials for live server ? Your local db username/password will not work over live server. – Niklesh Raut Jul 23 '16 at 11:42
  • @Rishi Thanx for the quick response. Yes credentials are allgood and i tried checking the value of $tcom on online server using print_r and the page was blank. But on local server value came: Array ( [1251] => Array ( [idstate] => 153 [ico] => 0 [name] =>..... – Taslim Jul 23 '16 at 12:07
  • how you sure about db connection is good? if query is same and not output ? If all good, you should check url/path. – Niklesh Raut Jul 23 '16 at 12:11
  • @Rishi ya i turned on the error reporting and it says: Fatal error: Uncaught exception 'Pph\ApiClientException' with message 'Unknown error HTTP/1.1 400 BAD REQUEST Server: nginx Date: Sat, 23 Jul 2016 12:15:36 GMT Content-Type: application/vnd+company.category+human Transfer-Encoding: – Taslim Jul 23 '16 at 12:18
  • I must say check file url's – Niklesh Raut Jul 23 '16 at 12:20
  • @Rishi i double checked the file url with a simple html code and it displayed fine. – Taslim Jul 23 '16 at 12:27
  • @Rishi error log: PHP Fatal error: Uncaught exception 'Pph\\ApiClientException' with message 'Unknown error HTTP/1.1 400 BAD REQUEST\r\nServer: nginx\r\nDate: Sat, 23 Jul 2016 12:02:54 GMT\r\nContent-Type: application/vnd+company.category+human\r\nTransfer-Encoding: chunked\r\nConnection: keep-alive\r\n\r\nArray\n(\n [error] => No data format defined. Please provide one (human, phpserialize, json) as URL parameter like this: &format=phpserialize\n)\n' – Taslim Jul 23 '16 at 12:46
  • error quote, code indenting – jwvh Jul 26 '16 at 00:56
  • Error 500 is usually a synonym for "an error occurred on the back-end". So check the server's PHP log to see what error is was, and let us know. – Fabien Haddadi Aug 24 '17 at 03:24

1 Answers1

0

Have to provide one (human, phpserialize, json) as URL parameter like this: &format=phpserialize\n)\n'

Example: $tcom = $ApiClient->apiCall('get', 'companies&format=phpserialize');

Taslim
  • 33
  • 9