A
A
Alex2016-10-15 09:53:38
Sphinx
Alex, 2016-10-15 09:53:38

SphinxQL in php?

Hello!
The bottom line is this, I'm trying to tie full-text search to php and it doesn't work:

error_reporting(E_ALL);ini_set("display_errors", 1);

$conn = new mysqli('localhost',null,null,null,3312);

$resource = $conn->query("SELECT * FROM `music` WHERE MATCH('sia') LIMIT 0,10");

if($resource->fetch_assoc()===true)	while ($row = $resource->fetch_assoc()){
  var_dump($row);
}

$resource->free_result();

Warning: mysqli::__construct(): (HY000/1045): Access denied for user ''@'localhost' (using password: NO) in /var/***/sphinx.php on line 5
Warning: mysqli::query(): Couldn't fetch mysqli in /var/***/sphinx.php on line 7
Fatal error: Uncaught Error: Call to a member function fetch_assoc() on null in /var/***/sphinx.php:9 Stack trace: #0 {main} thrown in /var/***/sphinx.php on line 9

Through the console, the rules enter without a password:
[email protected]:/# mysql -h 127.0.0.1 -P 3312                                                    
Welcome to the MySQL monitor.  Commands end with ; or \g.                                      
Your MySQL connection id is 1                                                                  
Server version: 2.0.4-id64-release (r3135)                                                     
                                                                                               
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.                   
                                                                                               
Oracle is a registered trademark of Oracle Corporation and/or its                              
affiliates. Other names may be trademarks of their respective                                  
owners.                                                                                        
                                                                                               
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.                 
                                                                                               
mysql> select * from music where match ('sia');

Config:
...
searchd{
workers = threads
compat_sphinxql_magics = 0
listen              = 3312:mysql41
log               = /var/log/sphinxsearch/searchd.log
query_log         = /var/log/sphinxsearch/query.log
read_timeout      = 5
max_children      = 30
pid_file          = /var/run/sphinxsearch/searchd.pid
max_matches       = 1000
seamless_rotate   = 1
preopen_indexes   = 1
unlink_old        = 1
binlog_path       = /var/lib/sphinxsearch/data/
binlog_max_log_size	= 12M
}
...

Tell me what am I doing wrong?
Z.Y: I tried other ports, also: with
Z.Z.Y: if I set 127.0.0.1 in the config and script, then it turns out the same

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alex, 2016-10-19
@logofiles

Solved via PDO

P
Puma Thailand, 2016-10-15
@opium

you forgot to show how you enter through the console
it is logical that the login password is not correct you enter

M
ManticoreSearch, 2018-04-08
@ManticoreSearch

mysqli, when you specify "localhost" as a host, ignores the specified port and tries to connect via unix socket. Using "127.0.0.1" instead of "localhost" solves this problem.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question