2014-05-09 6 views
2

mysqli_real_escape_string rend le programme bogué.FullText conduit à mauvais reults

J'ai une colonne Fulltext title. La fonctionnalité de texte intégral n'est pas dans phpMyadmin qui fonctionne après.

PhpMyadmin

- **id|title** 
- 1|cool boy 
- 2|cool bottle 
- 3|cool guy 
- 4|hot man 

UPDATE

file1.php

//from a form 

    $str = $_POST['q']; 
    $str=mysqli_real_escape_string($con,$str); 
    mysqli_query($con,"insert into tbl(title)values($str)"); 

file2.php
$str = $_GET['q']; 

$data = mysqli_query($con,"select * from tbl where match(title)against('$str')"); 
while($row = mysqli_fetch_assoc($data)){ 
    //do stuff . but yields nothing 
} 

Répondre

0

Essayez cette

select * from tbl where title LIKE '%cool%' 

EDIT: si vous voulez faire la recherche plein texte, puis modifier cette

against('cool') 

à

against('cool' IN BOOLEAN MODE) 

En MySQL, il y a trois types de temps plein recherches de texte:

  • recherche booléenne
  • recherche en langage naturel (utilisé par défaut)
  • recherche d'extension requête

De MySQL manual entry:

DEMO HERE

EDIT2:

faire file1.php

session_start(); //this will be in very top of your file 
    $str = $_POST['q']; 
    $_SESSION['str'] = $str; 
    $str=mysqli_real_escape_string($con,$str); 
    mysqli_query($con,"insert into tbl(title)values($str)"); 

dans file2.php

session_start(); //this will be in very top of your file 
    $str = $_SESSION['str']; 
    $data = mysqli_query(......... 
+0

rend trop lent besoin d'utiliser la recherche –

+0

texte intégral essayer et montrer le résultat s'il vous plaît 'SHOW TABLE STATUS' –

+0

vérifier ma réponse éditée. –

0
select * from tbl where title LIKE 'cool%' 

ajouter un seul % après votre chaîne/variables

Questions connexes