RE: [PHP] Whimper, help :)

From: Date: Wed, 04 Dec 2002 13:28:12 +0000
Subject: RE: [PHP] Whimper, help :)
Groups: php.general 
Request: Send a blank email to php-general+get-126975@lists.php.net to get a copy of this message
> -----Original Message----- > From: John Taylor-Johnston [mailto:taylorjo@collegesherbrooke.qc.ca] > Sent: 04 December 2002 06:28 > > http://ccl.flsh.usherb.ca/print/print.html?search=%26quot%3Bre > ady+maria%26quot%3B > http://ccl.flsh.usherb.ca/print/index.html?search=%26quot%3Bre > ady+maria%26quot%3B > > I blame PHP. Can't be MySQL. > echo $sql displays the EXACT same thing. > > Debugging ... Works jdaxell.ccl = 2 records found: > $sql = 'SELECT id,AU,ST,BT,AT FROM '.$table.' WHERE MATCH > (TNum,YR,AU,ST,SD,BT,BC,AT,PL,PR,PG,LG,AUS,KW,GEO,AN,RB,CO) > AGAINST (\'"ready maria"\' IN BOOLEAN MODE) ORDER BY id asc'; > http://ccl.flsh.usherb.ca/print/display.test.inc.phps > > > Doesn't work - Resembles +ready +maria > $sql = "SELECT id,AU,ST,BT,AT FROM $table WHERE MATCH > (TNum,YR,AU,ST,SD,BT,BC,AT,PL,PR,PG,LG,AUS,KW,GEO,AN,RB,CO) > AGAINST ('".stripslashes($search)."' IN BOOLEAN MODE) ORDER > BY id asc"; > http://ccl.flsh.usherb.ca/print/display.table.inc.phps > > Doesn't work - Resembles +ready +maria > $sql = "SELECT id,AU,ST,BT,AT FROM ".$table." WHERE MATCH > (TNum,YR,AU,ST,SD,BT,BC,AT,PL,PR,PG,LG,AUS,KW,GEO,AN,RB,CO) > AGAINST ('".stripslashes($search)."' IN BOOLEAN MODE) ORDER > BY id asc"; > http://ccl.flsh.usherb.ca/print/display.table.inc.phps > > > Doesn't work - Resembles +ready +maria > $sql = 'SELECT id,AU,ST,BT,AT FROM '.$table.' WHERE MATCH > (TNum,YR,AU,ST,SD,BT,BC,AT,PL,PR,PG,LG,AUS,KW,GEO,AN,RB,CO) > AGAINST (\''.stripslashes($search).'\' IN BOOLEAN MODE) ORDER > BY id asc'; > http://ccl.flsh.usherb.ca/print/display.table.inc.phps As far as I can see, *none* of these produce an identical query string to your hard-coded version -- they *all* have the double-quotes around the search string missing! Try this: $sql = 'SELECT id,AU,ST,BT,AT FROM '.$table.' WHERE MATCH (TNum,YR,AU,ST,SD,BT,BC,AT,PL,PR,PG,LG,AUS,KW,GEO,AN,RB,CO) AGAINST (\'"'.stripslashes($search).'"\' IN BOOLEAN MODE) ORDER BY id asc'; (BTW, I'm not sure you need the stripslashes() -- I don't use MySQL, so I can't be sure, but doesn't it need quotes to be backslash-escaped inside a quoted string?) Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@lmu.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#126975) next »