-1

I want to connect Fuseki Server to PHP following the instructions from Ontology and the Web . But I received an error while executing : "Didn't even see a sparql element, is this really an endpoint?" What changes should I make in the sparqllib.php file to access my fuseki server?

Any help would be appreciated. Thanks in advance.

Edit:

The code for accessing the tripplestore:

<?php
require_once( "sparqllib.php" );

$db = sparql_connect( "http://localhost:3030" );
if( !$db ) { print sparql_errno() . ": " . sparql_error(). "\n"; exit; }

sparql_ns( "foaf","http://xmlns.com/foaf/0.1/" );
sparql_ns("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
sparql_ns("rdfs", "http://www.w3.org/2000/01/rdf-schema#");

$sparql = "PREFIX : <http://localhost/soy_test1#> 
       SELECT ?P WHERE { ?PlantDescriptor :hasType ?P }";
$result = sparql_query( $sparql ); 
$fields = sparql_field_array( $result );

print "<p>Number of rows: ".sparql_num_rows( $result )." results.</p>";
print "<table class='example_table'>";
print "<tr>";
foreach( $fields as $field )
{
    print "<th>$field</th>";
}
print "</tr>";
while( $row = sparql_fetch_array( $result ) )
{
    print "<tr>";
    foreach( $fields as $field )
    {
        print "<td>$row[$field]</td>";
    }
    print "</tr>";
}
print "</table>";

Thanks in advance.

Community
  • 1
  • 1
user1790
  • 27
  • 7
  • 1
    Not enough information. But start from the error message. Did you really specify the URL of the Fuseki sparql endpoint correctly. – chrisis Mar 21 '17 at 09:30
  • Okay...that's actually what I was looking for...where should I specify the URL? Pardon me...this may be very basic...but I am newbie. – user1790 Mar 21 '17 at 10:02
  • 1
    http://localhost:3030 is not the name of a SPARQL endpoint. In Fuseki it will look like http://localhost:3030/NAME/sparql where NAME is the name you choose for your dataset. See the Fuseki query page which shows the URL. – AndyS Mar 21 '17 at 22:22
  • Thanks so much for your suggestion...it worked :) – user1790 Mar 22 '17 at 06:17

1 Answers1

0

I suggest you take a look at this example and replace http://rdf.ecs.soton.ac.uk/sparql/ with the URL of your sparql endpoint.

chrisis
  • 1,983
  • 5
  • 20
  • 17
  • Thanks for your help...but it still shows an XML error...I have added my code...I could not find what I am doing wrong...the sparql query is not working...though its working fine on fuseki. – user1790 Mar 21 '17 at 11:54