Page 1 of 1

PHP/SQL error, totally lost

Posted: Tue Nov 17, 2009 7:00 am
by angelicodin
Hi ya guys. Still new here but I've been doing my part and helping out where I can, and you all have been vary helpful so far.
So here we go. :D
I've ran into problem while trying to get fulltext to work with sql. I was thinking some fresh eyes would point out my mistake. :banghead:

Code: Select all

<?
$sql = "SELECT *, MATCH(search) AGAINST('".$search."' IN BOOLEAN MODE) AS score FROM testtable WHERE MATCH(search) AGAINST('".$search."' IN BOOLEAN MODE)";
while($sql2 = mysql_fetch_array($sql)) {
//output here   
}
?>
and I get
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/pages/fulltext.php on line 65
:dubious: Weird thing is when i echo(or print) the $sql and run that in sql, it works just fine. I'm not sure if it's a sql problem or i'm using the wrong php-mysql function.

Thoughts? And thanks for taking a look at this. :D

Re: PHP/SQL error, totally lost

Posted: Tue Nov 17, 2009 7:08 am
by iankent
You haven't run the query, i.e. using mysql_query($q), so when it gets to mysql_fetch_array there's nothing in the result to process. That's why the query works when you copy and paste it :)

hth

Re: PHP/SQL error, totally lost

Posted: Tue Nov 17, 2009 9:24 am
by angelicodin
:banghead: :banghead: :banghead: :banghead: :banghead: :banghead:
Oh my god, I feel like such and idiot...

Thanks for taking the time to look at it.