tags:

views:

35

answers:

1
$result=mysql_query("SELECT * FROM playerlocations WHERE player<>'0'");

$returntext="";

while($row=mysql_fetch_array($result))
{
if($returntext!=""){$returntext.="&";}
$returntext.=$row['player']."#".$row['locations'];
}

the error message claims that $result isn't a valid result set. I tested it in phpmyadmin, and it worked. I don't know why it won't work here, please help.

+3  A: 

It says it isn't a valid result set. That doesn't necessarily mean it isn't a valid query. (Although != instead of <> would be nice.)

To figure out why it's not valid, output the result of calling mysql_error() after running the query:

echo mysql_error(); //most direct way to do this

It will tell you what MySQL reports as the error message.

One obvious thing to check: have you opened the connection (with mysql_connecst()) before running the query?

VoteyDisciple
I forgot to select which DB, thanks.
Jcubed
wait... no, that wasn't the issue, its that i forgot to give my user perms for the DB...
Jcubed