Re: alternatives? (Was: Shot in the dark)

From: Date: Sat, 06 Jul 2002 20:42:25 +0000
Subject: Re: alternatives? (Was: Shot in the dark)
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-102597@lists.php.net to get a copy of this message
Clay, >I don't know exactly what your table structure is, and what fields you want >the fulltext search to check against, but you probably need to do something >like this: Just so I don't scare myself changing something here is my structure. What's wrong with it? Let's say I want to fulltext search in AU and AUS. How would these fields change? I would add another index, or ?? CREATE TABLE ccl_main ( id int(6) NOT NULL auto_increment, RNum int(11) NOT NULL default '0', TNum enum('','Article in a journal','Article in a popular periodical','Book','Book (translated / edition)','Book (in a series)','Book (extended form)','Chapter or Article in an edited book','Archival Records And Manuscripts','Article in a Journal (extended form)','Dissertation or Thesis','Film','Multivolume Work','Pamphlet or Monograph','Paper Presented at a Conference','Published Conference Proceedings','Technical Report','Unpublished Paper','Personal Communication','Full Record') NOT NULL default '', YR text NOT NULL, AU text NOT NULL, ST longtext NOT NULL, SD text NOT NULL, SC text NOT NULL, BT longtext NOT NULL, BD text NOT NULL, BC longtext NOT NULL, AT text NOT NULL, AD text NOT NULL, AC text NOT NULL, SR text NOT NULL, PL text NOT NULL, PR text NOT NULL, JR text NOT NULL, VNum text NOT NULL, INum text NOT NULL, DT text NOT NULL, PG text NOT NULL, LG text NOT NULL, SF text NOT NULL, OL longtext NOT NULL, KW longtext NOT NULL, AUS text NOT NULL, GEO text NOT NULL, AN longtext NOT NULL, RB longtext NOT NULL, CO longtext NOT NULL, PRIMARY KEY (id) ) TYPE=MyISAM COMMENT='CCL Bibliography - Bibliographie ECC'; Loveless wrote: > John, > > Sounds like you don't have your FULLTEXT indexes set up properly. > Double-check the instructions here: > http://www.mysql.com/doc/F/u/Fulltext_Search.html > > I don't know exactly what your table structure is, and what fields you want > the fulltext search to check against, but you probably need to do something > like this: > > mysql> ALTER TABLE your_table ADD FULLTEXT(textfield1, textfield2); > > Or: > > <? > mysql_query("ALTER TABLE $table ADD FULLTEXT (textfield1, textfield2)"); > ?> > > -Clay > > > From: jtjohnston <taylorjo@collegesherbrooke.qc.ca> > > Reply-To: jtjohnston@courrier.usherb.ca > > Date: Sat, 06 Jul 2002 16:28:05 -0400 > > To: php-general@lists.php.net > > Subject: Re: [PHP] alternatives? > > > > Clay, > > > > That works! Thanks. > > > > $news = mysql_query("SELECT * FROM $table WHERE MATCH (AU) AGAINST ('.$au.' > > IN > > BOOLEAN MODE) order by AU desc"); > > > > Are there any other alternatives to "in boolean mode"? I tried this: > > > > http://www.mysql.com/doc/F/u/Fulltext_Search.html > > $news = mysql_query("SELECT * FROM $table WHERE MATCH (AU) AGAINST > > ('.$au.') > > order by AU desc"); > > > > But get this error: "Can't find FULLTEXT index matching the column list" > > > > John > > > > Loveless wrote: > > > >> Try this: > >> > >> $news = mysql_query("select * from $table where AU like '$au' order by > >> AU > >> desc"); > >> > >> -Clay > >> > >>> From: jtjohnston <taylorjo@collegesherbrooke.qc.ca> > >>> Reply-To: jtjohnston@courrier.usherb.ca > >>> Date: Sat, 06 Jul 2002 16:08:16 -0400 > >>> To: php-general@lists.php.net > >>> Subject: Re: [PHP] Shot in the dark > >>> > >>> Rasmus, > >>> > >>> Warning: Supplied argument is not a valid MySQL result resource in > >>> c:\program > >>> files\easyphp\ccl_www\db1\index.html on line 45 > >>> You have an error in your SQL syntax near ' Margaret order by AU desc' > >>> at > >>> line > >>> 1 > >>> > >>> So it doesn't like my "," (comma) ? > >>> > >>> $au ="Atwood, Margaret"; > >>> $id ="1624"; > >>> > >>> #$news = mysql_query('select * from '.$table.' where id like > >>> '.$id.' order > >>> by > >>> AU desc'); > >>> $news = mysql_query('select * from '.$table.' where AU like > >>> '.$au.' order by > >>> AU desc'); > >>> #$news = mysql_query('SELECT * FROM '.$table.' WHERE MATCH (AU) > >>> AGAINST > >>> ('.$au.' IN BOOLEAN MODE) order by AU desc'); > >>> > >>> while ($mydata = mysql_fetch_object($news)) > >>> { > >>> $mycounter++; > >>> echo $mydata->id." - ".$mydata->AU."<hr>"; > >>> } > >>> > >>> if(!$news) die(mysql_error()); > >>> > >>> > >>> > >>> > >>> Lerdorf wrote: > >>> > >>>> If you added some error-checking you'd know right away. > >>>> > >>>> ie. after your mysql_query() call. > >>>> > >>>> if(!$news) die(mysql_error()); > >>>> > >>>> -Rasmus > >>>> > >>>> On Sat, 6 Jul 2002, jtjohnston wrote: > >>>> > >>>>> MySQL4 installation. I don't get this. One mysql_query works, the > >>>>> other > >>>>> 2 don't. What did I mess up in my PHP syntax? > >>>>> The SQL queries all work. > >>>>> > >>>>> $au ="Atwood, Margaret"; > >>>>> $id ="1624"; > >>>>> > >>>>> THIS WORKS: > >>>>> $news = mysql_query('select * from '.$table.' where id like > >>>>> '.$id.' > >>>>> order by AU desc'); > >>>>> > >>>>> This gives "Warning: Supplied argument is not a valid MySQL result > >>>>> resource ... on line 48": > >>>>> $news = mysql_query('select * from '.$table.' where AU like > >>>>> '.$au.' > >>>>> order by AU desc'); > >>>>> #SQL-Query works: select * from ccl_main where AU like 'Atwood, > >>>>> Margaret' order by AU desc > >>>>> > >>>>> This gives "Warning: Supplied argument is not a valid MySQL result > >>>>> resource ... on line 48": > >>>>> $news = mysql_query('SELECT * FROM '.$table.' WHERE MATCH > >>>>> (AU) AGAINST > >>>>> ('.$au.' IN BOOLEAN MODE) order by AU desc`'); > >>>>> #SQL-Query works: SELECT * FROM ccl_main WHERE MATCH (AU) AGAINST > >>>>> ('Atwood, Margaret' IN BOOLEAN MODE) order by AU desc > >>>>> > >>>>> while ($mydata = mysql_fetch_object($news)) <----- this is > >>>>> line > >>>>> 48 > >>>>> { > >>>>> $mycounter++; > >>>>> echo $mydata->id." - > >>>>> ".$mydata->AU."<hr>"; > >>>>> } > >>>>> > >>>>> > >>>>> > >>>>> -- > >>>>> PHP General Mailing List (http://www.php.net/) > >>>>> To unsubscribe, visit: > >>>>> http://www.php.net/unsub.php > >>>>> > >>> > >>> > >>> -- > >>> PHP General Mailing List (http://www.php.net/) > >>> To unsubscribe, visit: > >>> http://www.php.net/unsub.php > >>> > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#102597) next »