-4
$query_user2 = mysql_query("SELECT TOP 1 * FROM $var WHERE id = (rand() * (SELECT MAX(id) FROM $var))");
$estrai2 = mysql_fetch_array($query_user2);  

Problem: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

Why? :/

2
  • 2
    Please at least glance at the hundreds of questions about that error message here and elsewhere. Look at the "Related" sidebar for a start. Commented Nov 16, 2013 at 9:35
  • 1
    Probably because you have a syntax error in your query. Look at mysql_error() after you've run the query to find out what is happening. Commented Nov 16, 2013 at 9:35

1 Answer 1

1

TOP 1 is a sql server ( not MySQL ) command to select the first row, remove that and add LIMIT 1 to the end of the query.

you might want to alter your question. The problem is your query, not the "supplied argument is not a valid mysql result"

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.