error while trying to use MySQL fulltext search ...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
HormonX
Forum Commoner
Posts: 50
Joined: Tue Dec 10, 2002 7:43 pm
Location: Toronto

error while trying to use MySQL fulltext search ...

Post by HormonX »

I am trying to use full text search and am getting an error while i try to run the code.

Code: Select all

$query = "SELECT oid, MATCH (ad,oid) AGAINST ('$searchfor') FROM adtable";
$result = mysql_query($query, $link);
	
$row = mysql_fetch_row($result);

echo $rowї0];
This is the error i am getting ...

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/domain/public_html/portal/htmle/adpage.php on line 27



i belive that it has something to do with the $query statement ... but i just can't figure out what.

can anyone help ?

Greg
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

echo out mysql_error()
HormonX
Forum Commoner
Posts: 50
Joined: Tue Dec 10, 2002 7:43 pm
Location: Toronto

Post by HormonX »

i echo-ed mysql_error() and got that issue fixed .. but now a new problem came about ... i don't see any results. ....

Code: Select all

$query = "SELECT * FROM table WHERE MATCH column AGAINST ('$searchfor')";
$result = mysql_query($query, $link);
	
			while($r = mysql_fetch_array($result))
		{

				$var = $rї'var'];
				
				echo "$var";
		}
this is what i do ... it worked a 1000 times before but now it doesn't . I tried using a for() loop to show only for example 20 results ... but nothing. Can anyone tell me what am i doing wrong ?

Thank you.
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Add this at the top of the script:

Code: Select all

ini_set('error_reporting', E_ALL);
Works well for debugging as alot of people have the levels set down to low to see mistakes...
--

Is var a fieldname in the database? Change it to

Code: Select all

{
    // $var = $rї0];
    // echo $var;
    print_r($r);
}
...ad see if that leads you anywhere.

Use

Code: Select all

echo $query;
after setting it so you see that youre sure that is in order.
Cronikeys
Forum Commoner
Posts: 35
Joined: Sun Jan 16, 2005 9:14 am

Post by Cronikeys »

Also maybe post more of the script? I am usually very good at debugging :D
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Cronikeys wrote:Also maybe post more of the script? I am usually very good at debugging :D
Yah please, don't take me wrong. I'm just making sure. =)

Try the same query in phpmyadmin or it's likes and see if at least that works. I'm no longer amazed at simple things making big bugs...

Still no luck, do paste more code or show_source() it somewhere.
HormonX
Forum Commoner
Posts: 50
Joined: Tue Dec 10, 2002 7:43 pm
Location: Toronto

Post by HormonX »

i think i just tried just about everything and still having problems with full text search. I have tried to run a query withing phpmyadmin to see if it will work .. and guess what ... a big nothing.

Query is being executed without a problem but no results are being displayed. Not sure why this is not working right. I will try to investigate this issue further .. but later on. I have to concentrate of other functions of the site.

For now i am using s very simple method of searching ... i guess you can call it that using LIKE string in MySQL statement, it works for now and it will not be a heavy trafic site ... for now i will just leave it at that and try to solve the issue with full text search later.

thanx for your help :)

greg

btw ... can anyone help me with finding a way to create dependable pull down menu ? I would like to use java script and php so i don't have to refresh the page after initial selection. My javascript is as good as my french :) therefore i need some major help :) anyone can point me in the right direction ?
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post by AGISB »

Did you add the fulltext index to the fields you want to search?

Also remember that all words less than 4 letters will yield a big nothing unless you set the mysql setting to a lower number.
HormonX
Forum Commoner
Posts: 50
Joined: Tue Dec 10, 2002 7:43 pm
Location: Toronto

Post by HormonX »

AGISB wrote:Did you add the fulltext index to the fields you want to search?

Also remember that all words less than 4 letters will yield a big nothing unless you set the mysql setting to a lower number.
Sure did ... am not sure what i was doing wrong ... for now i just used easy way out .. and it works just fine. I will try to get full text search going down the road.
Post Reply