RE: [PHP] random?
| From: | Chris | Date: | Thu, 29 Jan 2004 22:35:06 +0000 |
| Subject: | RE: [PHP] random? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-176266@lists.php.net to get a copy of this message | ||
Warning: mysql_result(): supplied argument is not a valid MySQL result
resource in /home/virtual/site17/fst/var/www/html/function.php on line 51
Warning: mysql_free_result(): supplied argument is not a valid MySQL result
resource in /home/virtual/site17/fst/var/www/html/function.php on line 52
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in /home/virtual/site17/fst/var/www/html/function.php on line 58
I get the above repeating errors when I aply the code below to the random
function:
49 srand ((double) microtime() * 1000000);
50 $r = mysql_query('select count(*) as cnt from agentdb');
51 $cnt = mysql_result($r, 0, 0);
52 mysql_free_result($r);
53 $rnd = rand(1, $cnt);
54 $sql = "SELECT * FROM agentdb WHERE ((OfficeID <> 214) and
(agentdb.agent_id<> 1115421) and(agentdb.agent_id > 100) and
agentdb.agent_id <> 333)) LIMIT $rnd, 1";
56
57 $results= mysql_query($sql);
58 $agent=mysql_fetch_array($results);
59 $agent_ref = $agent['agent_ref'];
60 $agent_id = $agent['agent_id'];
61 $agent_first = $agent['agent_first'];
62 $agent_last = $agent['agent_last'];
63 $agent_first = rawurldecode($agent_first);
64 $agent_last = rawurldecode($agent_last);
65 $aimage= "agentpics/".$agent_id.".jpg";