BASEX and PHP: for $node in doc("factbook") -- ERROR: Unknow

Monday, 26 July 2010 · 1 message
J
johanna.vompras26 Jul 2010 12:12 #
Hi all! I have written some PHP Scrips with test queries to the factbook database, which are are well executed at my local machine (Windows, XAMPP, BaseX on localhost, Port 1984). Now, I have ported my examples to a remote server, and it seams that the query string is not accepted. For example: The query (for $node in doc("allbus")//(d:QuestionItem|d:MultipleQuestionItem) return data($node/@id)') results in the following error: Unknown command 'for'; try "help". Other queries result in Error: 0 instead of 1 commands received. We have BaseX Client running and the queries can be submitted through the linux console (> xquery for $node in doc("factbook")//country return $node). Opening the database and querying also works. But from my PHP scripts it does not work. Does anybody know went wrong with my installation? Here is the example:
<?php
include('BaseXClient.php');
//set content-type header
header('Content-type: application/json');

// commands to be performed
$namespaces = 'declare namespace d="ddi:datacollection:3_0";';
$cmd = 'for $node in doc("allbus")//(d:QuestionItem|d:MultipleQuestionItem) return data($node/@id)';
$cmd2 = 'for $node in doc("allbus") //(d:QuestionItem|d:MultipleQuestionItem)/d:QuestionText/d:LiteralText/d:Text return data($node)';
try {
// create session
  $session = new Session("129.......", 9000, "admin", "admin");

//create JSON data structure
  $startJsonObject = "{ questions: [";
  $endJsonObject = "]}";

  try {
    $query = $session->query($namespaces.$cmd);
	$query2 = $session->query($namespaces.$cmd2);
	$counter = 0;
    while($query->more()) {
      $next = $query->next();
	  $query2->more();
      $next2 = $query2->next();
	  $counter++;
................ etc... ?>

⚡Generated with XQuery