Hi Ahmet,

Taking the sample query and code you provide I have been able to see the error being reported by the PHP client. Having turned on internal debugging on the Virtuoso server hosting DBpedia I do not see the query hitting the server so I assume the problem is in the PHP client. So as Jens suggest you probably should look at the params that can be passed to the PHP curl client based on the possible causes reported to see if the query can be made to run. I shall do some reading myself to see if I can get it to work with my PHP client (which is a Virtuoso Server with PHP runtime hosting support by the way :-))

Best Regards
Hugh Williams
Professional Services
OpenLink Software
Web: http://www.openlinksw.com
Support: http://support.openlinksw.com
Forums: http://boards.openlinksw.com/support



On 31 Mar 2009, at 16:24, Ahmet YILDIRIM wrote:

Thank you for answering my question.

When I apply the code below:

$sparql_query=" SELECT ?label WHERE { ?label  ?a ?b} ";
$c = curl_init();
$headers = array("Accept: application/sparql-results+html");
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_URL, "http://dbpedia.org/sparql";);
curl_setopt($c, CURLOPT_HTTPHEADER, $headers);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, "query=".urlencode ($sparql_query));
$result = curl_exec($c);
echo curl_error($c);
curl_close($c);
echo $result;

I get the results as expected.

However, when I change sparql_query line with below:

$sparql_query="SELECT ?label WHERE { { ?a <http://dbpedia.org/ resource/Turkey> <http://dbpedia.org/resource/Capital> . } UNION { <http://dbpedia.org/resource/Turkey> ?a <http://dbpedia.org/ resource/Capital> . } UNION { <http://dbpedia.org/resource/ Turkey> <http://dbpedia.org/resource/Capital> ?a . } UNION { ?a <http://dbpedia.org/resource/Turkey> <http://dbpedia.org/property/ capital> . } UNION { <http://dbpedia.org/resource/Turkey> ?a <http://dbpedia.org/property/capital> . } UNION { <http:// dbpedia.org/resource/Turkey> <http://dbpedia.org/property/capital> ? a . } UNION { ?a <http://dbpedia.org/property/turkey> <http:// dbpedia.org/resource/Capital> . } UNION { <http://dbpedia.org/ property/turkey> ?a <http://dbpedia.org/resource/Capital> . } UNION { <http://dbpedia.org/property/turkey> <http://dbpedia.org/ resource/Capital> ?a . } UNION { ?a <http://dbpedia.org/property/ turkey> <http://dbpedia.org/property/capital> . } UNION { <http:// dbpedia.org/property/turkey> ?a <http://dbpedia.org/property/ capital> . } UNION { <http://dbpedia.org/property/turkey> <http:// dbpedia.org/property/capital> ?a . } UNION { ?a <http:// dbpedia.org/resource/Capital> <http://dbpedia.org/resource/ Turkey> . } UNION { <http://dbpedia.org/resource/Capital> ?a <http://dbpedia.org/resource/Turkey> . } UNION { <http:// dbpedia.org/resource/Capital> <http://dbpedia.org/resource/Turkey> ? a . } UNION { ?a <http://dbpedia.org/resource/Capital> <http:// dbpedia.org/property/turkey> . } UNION { <http://dbpedia.org/ resource/Capital> ?a <http://dbpedia.org/property/turkey> . } UNION { <http://dbpedia.org/resource/Capital> <http://dbpedia.org/ property/turkey> ?a . } UNION { ?a <http://dbpedia.org/property/ capital> <http://dbpedia.org/resource/Turkey> . } UNION { <http:// dbpedia.org/property/capital> ?a <http://dbpedia.org/resource/ Turkey> . } UNION { <http://dbpedia.org/property/capital> <http:// dbpedia.org/resource/Turkey> ?a . } UNION { ?a <http:// dbpedia.org/property/capital> <http://dbpedia.org/property/ turkey> . } UNION { <http://dbpedia.org/property/capital> ?a <http://dbpedia.org/property/turkey> . } UNION { <http:// dbpedia.org/property/capital> <http://dbpedia.org/property/turkey> ? a . } . ?a rdfs:label ?label . FILTER (LANG(?label) = 'en')}";

I get:


ERROR
The requested URL could not be retrieved

While trying to process the request:

POST /sparql HTTP/1.1
Host: dbpedia.org
Accept: application/sparql-results+html
Content-Length: 3129
Content-Type: application/x-www-form-urlencoded
Expect: 100-continue


The following error was encountered:

   * Invalid Request

Some aspect of the HTTP Request is invalid. Possible problems:

   * Missing or unknown request method
   * Missing URL
   * Missing HTTP Identifier (HTTP/1.0)
   * Request is too large
   * Content-Length missing for POST or PUT requests
   * Illegal character in hostname; underscores are not allowed

Your cache administrator is webmas...@openlinksw.com.



Where am i doing wrong?

Thanks in advance again.
Ahmet

On Tue, Mar 31, 2009 at 5:28 PM, Jens Lehmann <lehm...@informatik.uni-leipzig.de> wrote:
>
> Hello,
>
> Jens Lehmann schrieb:
>  > Hello,
>  >
>  > $headers = array("Content-Type: ".$this->contentType);
>  > $c = curl_init();
>  > curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
>  > curl_setopt($c, CURLOPT_URL, $url);
>  > curl_setopt($c, CURLOPT_HTTPHEADER, $headers);
>  > $contents = curl_exec($c);
>  > curl_close($c);
>
> Here is the corresponding POST code:
>
> $c = curl_init();
> $headers = array("Accept: application/sparql-results+JSON");
> curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
> curl_setopt($c, CURLOPT_URL, "http://dbpedia.org/sparql";);
> curl_setopt($c, CURLOPT_HTTPHEADER, $headers);
> curl_setopt($c, CURLOPT_POST, true);
> curl_setopt($c, CURLOPT_POSTFIELDS, "query=$query");
> $contents = curl_exec($c);
> echo curl_error($c);
> curl_close($c);
>
> Kind regards,
>
> Jens
>
>
> ---------------------------------------------------------------------- --------
> _______________________________________________
> Dbpedia-discussion mailing list
> Dbpedia-discussion@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion
>

---------------------------------------------------------------------- --------
_______________________________________________
Dbpedia-discussion mailing list
Dbpedia-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion

------------------------------------------------------------------------------
_______________________________________________
Dbpedia-discussion mailing list
Dbpedia-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion

Reply via email to