Hi,

Thursday, December 5, 2002, 3:39:20 AM, you wrote:
JTJ> What are magic quotes? Will this help me?

JTJ> http://news.php.net/article.php?group=php.general&article=126934

JTJ> How is this different from stripslashes.

JTJ> I have RTF doc :)

JTJ> http://www.php.net/manual/en/function.get-magic-quotes-gpc.php

JTJ> Be gentil ::p

JTJ> --
JTJ> John Taylor-Johnston
JTJ> -----------------------------------------------------------------------------
JTJ> "If it's not open-source, it's Murphy's Law."

JTJ>    -     Université de Sherbrooke:
JTJ>           http://compcanlit.ca/



magic quotes are slashes that are added to post and get data by PHP
That is probably what is stuffing up :)
I replied to an earlier thread with a possible solution but here it is again...


function clean_search_string($s){
        $s = stripslashes($s);
        $state = 'S';
        $len = strlen($s);
        $out = '';
        $list = array();
        for($i=0;$i<$len;$i++){
                switch($state){
                        case 'S':
                                switch($s[$i]){
                                        case ' ':
                                        break;
                                        case '"':
                                                $state = 'Q';
                                        break;
                                        case "'":
                                                $state = 'q';
                                        break;
                                        default:
                                                $state = 'W';
                                                $out .= $s[$i];
                                        break;
                                }
                        break;
                        case 'W':
                                switch($s[$i]){
                                        case ' ':
                                                $state = 'S';
                                                $out = addslashes($out);
                                                $list[] = $out;
                                                $out = '';
                                        break;
                                        default:
                                                $out .= $s[$i];
                                        break;
                                }
                        break;
                        case 'Q':
                                switch($s[$i]){
                                        case '"':
                                                $state = 'S';
                                                $out = '"'.addslashes($out).'"';
                                                $list[] = $out;
                                                $out = '';
                                        break;
                                        default:
                                                $out .= $s[$i];
                                        break;
                                }
                        break;
                        case 'q':
                                switch($s[$i]){
                                        case "'":
                                                $state = 'S';
                                                $out = '"'.addslashes($out).'"';
                                                $list[] = $out;
                                                $out = '';
                                        break;
                                        default:
                                                $out .= $s[$i];
                                        break;
                                }
                        break;
                }
        }
        if(!empty($out)) $list[] = addslashes($out);;
        $r = '';
        $x = 0;
        while(list($key,$val)=each($list)){
                $r .= $val.' ';
        }
        return $r;
}
$test = addslashes(' +test "hello maria" fish '."-O'Brian 'big \" test'");
$list = clean_search_string($test);
echo $list.'<br>';


you will then just need "SELECT.......... AGAINST '$list' ....  "

-- 
regards,
Tom


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to