PHP/SQL error, totally lost

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
User avatar
angelicodin
Forum Commoner
Posts: 81
Joined: Fri Nov 13, 2009 3:17 am
Location: Oregon, USA

PHP/SQL error, totally lost

Post 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
User avatar
iankent
Forum Contributor
Posts: 333
Joined: Mon Nov 16, 2009 4:23 pm
Location: Wales, United Kingdom

Re: PHP/SQL error, totally lost

Post 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
User avatar
angelicodin
Forum Commoner
Posts: 81
Joined: Fri Nov 13, 2009 3:17 am
Location: Oregon, USA

Re: PHP/SQL error, totally lost

Post 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.
Post Reply