Re: MySQL error, what's wrong here..
| From: | Wagner Tomy | Date: | Tue, 24 Jul 2001 09:47:44 +0000 |
| Subject: | Re: MySQL error, what's wrong here.. | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-59320@lists.php.net to get a copy of this message | ||
try this:
$query = "SELECT songname FROM mp3 WHERE sgid = \"$id\"";
(or a little cleaner: $query = sprintf("SELECT songname FROM mp3 WHERE
sgid = \"%d\"", $id); )
instead of:
$query = "SELECT songname FROM mp3 WHERE sgid = " .$id;
----- Original Message -----
From: "James Holloway" <james@towntalk.co.uk>
To: <php-general@lists.php.net>
Sent: Tuesday, July 24, 2001 11:05 AM
Subject: Re: [PHP]MySQL error, what's wrong here..
> 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
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>