0

I'm trying to use the sphinx api to grab some data from a mysql db, but I keep getting this error when I load it on my browser.

Query failed: connection to localhost:3306 failed (errno=4, msg=).

I had no luck when I tried changing the port number to 3312, and a few others..

I was actually able to get results for queries through linux command, but the error occurs when I try it (using the sphinxapi.php file) on my browser

code:

include('sphinxapi.php');

$cl = new SphinxClient();
$cl->SetServer("localhost", 3306);

$cl->SetMatchMode( SPH_MATCH_ANY  );
$result = $cl->Query("email");


if ( $result === false ){ 
      echo "Query failed: " . $cl->GetLastError() . ".\n";
}
else{
    print_r($result);
}

I'm using sphinx 0.9.8

steve
  • 3,878
  • 7
  • 34
  • 49

2 Answers2

3

Thanks guys, I actually figured it out. I used my server ip instead of "localhost".

steve
  • 3,878
  • 7
  • 34
  • 49
0

Make sure your sphinx search daemon is running and listening on port 3306

ajreal
  • 46,720
  • 11
  • 89
  • 119
  • It actually is. But it looks like it makes no difference because if I leave everything default to port 3312, it still gives me the error saying, connection to localhost:3312 failed – steve Dec 04 '10 at 08:32
  • 1
    @barjonah - try `ps afx | grep searchd` , see the searchd is up and running, and look for `listen` in the configuration for the searchd – ajreal Dec 04 '10 at 08:35