-1

I've been playing around with this query for a while but I'm getting the:

    Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in 
C:\xampp\htdocs\Manny\FantasyMockProject\test.php on line 50

Which is telling me I'm not using the query correctly. My original query is like so:

$simulateQuery1 = mysql_query("SELECT * FROM player2 WHERE 
preranking >= " .$_SESSION['max_pick']. " ORDER BY RAND() LIMIT 1");

I want to return all columns from the player2 table where preranking >= $_SESSION['max_pick'] also I want to include the ORDER BY RAND() LIMIT 1

Is this possible using only 1 query? Thanks.

[EDIT: Found the mistake. I had missing ' ' around my Session variable.]

GeekByDesign
  • 374
  • 2
  • 3
  • 12

1 Answers1

1

Your query is broken. The reason is that you should add a space before ORDER. So basically:

$simulateQuery1 = mysql_query("SELECT * FROM player2 WHERE 
preranking >= " .$_SESSION['max_pick']. " ORDER BY RAND() LIMIT 1");

The error message says "boolean given" because a broken query returns FALSE, which is a boolean.

David
  • 114
  • 1
  • 4