RE: [PHP]MySQL error, what's wrong here..
| From: | Tim Ward | Date: | Tue, 24 Jul 2001 08:03:34 +0000 |
| Subject: | RE: [PHP]MySQL error, what's wrong here.. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-59311@lists.php.net to get a copy of this message | ||
my guess would be that sgid is a character field. if this isn't the case
then try hardcoding a known id into the query and seeing what happens. It
could also be that the connection has failed, try something like:
if ($connection = mysql_connect())
{
...
$id = rand(1,2);
$query = "SELECT songname FROM mp3 WHERE sgid = " .$id;
if ($result = mysql_query($query,$connection))
{ $mp3d = mysql_fetch_array($result);
...
} else echo("query failed");
...
} else echo("connection failed");
this'll give you an idea of where it's going wrong
Tim Ward
Senior Systems Engineer
Please refer to the following disclaimer in respect of this message:
http://www.stivesdirect.com/e-mail-disclaimer.html
> -----Original Message-----
> From: Chris Cocuzzo [mailto:cuzo@mediaone.net]
> Sent: 23 July 2001 23:57
> To: php-general@lists.php.net
> Subject: [PHP]MySQL error, what's wrong here..
>
>
> <?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
>
>