0

i am newbie in cassnadra.

i want to show cassnadra data with php.

i tried with netbeans and it worked.( my os is linux) my question is why it does not work in web browser. is anybody there to answere me.

does it related to web browser's permision ???????

<?php

//use Cassandra;

//require_once 'Cassandra.php';
error_reporting(-1);
ini_set('display_errors', 'On');


$cluster   = Cassandra::cluster()                 // connects to localhost by default
                 ->build();

$keyspace  = 'new';
$session   = $cluster->connect($keyspace);        // create session, optionally scoped to a keyspace
$statement = new Cassandra\SimpleStatement(       // also supports prepared and batch statements
    'SELECT * FROM new.country_by_id');

$future    = $session->executeAsync($statement);  // fully asynchronous and easy parallel execution
$result    = $future->get();                      // wait for the result, with an optional timeout

foreach ($result as $row) {                       // results and rows implement Iterator, Countable and ArrayAccess
    print  $row['country_name']."<br />";


}


?>

it work in cmd but not work in web browser.

pls help

thank you

Erick Ramirez
  • 13,964
  • 1
  • 18
  • 23
  • after this code: `$session = $cluster->connect($keyspace); print "jijijij";` it does not show any data. – Veronica Nov 13 '17 at 07:02
  • PHP is server side and the output created with it is interpreted by a browser, the problem will be with the browser you are using and not the php code I expect. – pokeybit Nov 15 '17 at 12:36
  • Try firefox, then firefox quantum, chrome and even safari. Let us know the results please – pokeybit Nov 15 '17 at 12:37
  • Enable error logging with php `error_reporting(-1);ini_set('display_errors', 'On');` at the top of your code (after `session_start();`) if you have it there. – pokeybit Nov 15 '17 at 12:41
  • i use **error_reporting(-1);ini_set('display_errors', 'On');** at top of my code ,this messege **Fatal error: Uncaught Error: Class 'Cassandra' not found in /var/www/html/test.php:7 Stack trace: #0 {main} thrown in /var/www/html/test.php on line 7** was shown. – Veronica Nov 16 '17 at 05:52
  • without this **error_reporting(-1);ini_set('display_errors', 'On');** browser shows :**localhost is currently unable to handle this request. HTTP ERROR 500** – Veronica Nov 16 '17 at 05:55
  • i used google chrome , restart cassndra and apache2 , i also added **extension:cassandra.so** at etc/php/7.1/apache2/php.ini and etc/php/7.1/cli/php.ini and with php 7.0 **but not worked** – Veronica Nov 16 '17 at 06:31
  • With the error reporting on, it states that Cassandra has not loaded. `/var/www/html/test.php` **localhost is currently unable to handle this request. HTTP ERROR 500** is a mysql error that arises 'after' cassandra had failed to load – pokeybit Nov 16 '17 at 07:49
  • Amend you post with the contents of `test.php` please. Place it in a code block and remember to remove any sensitive information such as passwords or private locations. – pokeybit Nov 16 '17 at 07:51
  • Is line 7: `$future = $session->executeAsync($statement);` ? – pokeybit Nov 16 '17 at 07:53
  • how can i load cassandra in my code?i dont know that????????? – Veronica Nov 16 '17 at 09:49
  • `//require_once 'Cassandra.php';` remove the `//` – pokeybit Nov 16 '17 at 10:44
  • how can i know cassandra class address. i used usr/share/php/docs/cassandra/doc/cassandra.php but it can not works , with this messege **"Warning: require_once(usr/share/php/docs/cassandra/doc/cassandra.php): failed to open stream: No such file or directory in /var/www/html/test.php on line 8"** – Veronica Nov 18 '17 at 10:21
  • You will need to find out where it is located and use the correct path with `require_once` – pokeybit Nov 18 '17 at 13:51
  • thank you for you'r help but i dont know what to do yet.in fact i search in google but i dont find any thing of that which library should included. – Veronica Nov 20 '17 at 07:00

0 Answers0