Re: MySQL error, what's wrong here..
| From: | James Holloway | Date: | Tue, 24 Jul 2001 09:05:49 +0000 |
| Subject: | Re: MySQL error, what's wrong here.. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-59315@lists.php.net to get a copy of this message | ||
Hi Chris,
If you're using MySQL 3.23+, you might want to consider using something
like:
SELECT songname FROM mp3 ORDER BY RAND() LIMIT 1
Not that this answers your original problem, but it seems to make more sense
than manually coding a random number (which is, perhaps, impractical
especiallyif you plan to add / take away entries to your table on a regular
basis).
James
"Chris Cocuzzo" <cuzo@mediaone.net> wrote in message
news:014d01c113ca$dd3bf460$0300a8c0@mediaone.net...
> <?php
> $id = rand(1,2);
> $query = "SELECT songname FROM mp3 WHERE sgid = " .$id;
> $result = mysql_query($query,$connection);
> $mp3d = mysql_fetch_array($result);
> ?>
>
> the server is telling me line 43(which starts with $mp3d) is not a valid
> mysql result resource. what am i doing wrong??
>
> chris
>