That just gives me "Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource..." on the line with the while loop. Which just means the query failed right? I'm not sure what you mean by:
$results = mysql_query("SELECT column1, column2, date, time FROM table ORDER BY RAND() LIMIT 1");
$row_table = mysql_fetch_row($results);
I do not receive an error with this, but no results. I have another php file that does a similar query to the same database and it works fine. Why would it work with ORDER BY RAND() LIMIT 2 but not ORDER BY RAND() LIMIT 1? Also, I am not sure if I mentioned this, but when I use a LIMIT of 2, it only returns one result. I just don't get it.
Maybe we should start by asking whatt you are trying to accomplish with this query.
"Order BY" refers to how mysql returns the sort order. How does a random floating point between 0 and one do anything useful in this context?
I wonder how how you got any results at all.
Maybe we should start by asking whatt you are trying to accomplish with this query.
"Order BY" refers to how mysql returns the sort order. How does a random floating point between 0 and one do anything useful in this context?
I wonder how how you got any results at all.
JRM,
The query is for recommendations, it is meant to randomize the results to get something different each time. Thus, the order by rand. By default how is a query ordered, by id I would assume? Doesn't do me much good if it displays the same values every time does it? If you have a better way I'm all ears.
Thanks cwarn, I will give that a try. I just don't understand why the same query in a different script and same database, just different data, works fine. I will let you know the results.
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.