Jump to content

[SOLVED] Selecting and using data from a database


Errant_Shadow

Recommended Posts

I gave a game where players can win a prize if they have the best game of the day.

 

So I am writing a script that will assign a winner for the previous day if one is not already assigned.

 

The winner is the player who finished his round with the least number of guesses (clicks) in the least amount of time (play_time)

 

So my first question is, can you order a query by 2 fields? (both clicks and play_time)

 

My second question is, what is wrong with my script (below)? When I run it, it tells me

"Warning:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /.../test.php on line 12"

 

10    $query = "SELECT 'game_id' FROM 'games' WHERE date='$yesterday' ORDER BY 'clicks' ASC";
11    $result = mysql_query($query);
12    $winningGame = mysql_fetch_array($result, MYSQL_NUM);
13    echo 'Game ' . $winningGame[0] . ' selected...';
14    $query = "UPDATE games SET win='1' WHERE game_id='$winningGame[0]'";
15    $result = mysql_query($query);
16    if(mysql_affected_rows() > 0){
17        echo 'Game ' . $result . ' updated...';
18    } else {
19        echo 'error...';
20    }

 

Server version: 5.0.67-community

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.