Re: [PHP-DB] numeric string to single digit array

[email protected] (Evert Lammerts)
Newsgroups php.db
Message-ID <[email protected]>
> PHP is telling me that the resource I am using for mysql_fetch_assoc is invalid:
>
> $query ="Select answer from answers where studentID ='A123456789'";
> $result = mysql_query($query,$connection);
> $count=0;
> while($row = mysql_fetch_assoc($result));
> {
> $count++;
> }
> echo $count;
>   

Are you sure your database connection has been made?

$connection = mysql_connect('localhost', 'mysql_user', 'mysql_password') 
or die(mysql_error());
etc..

If the connection is made alright, try:

$query ="Select answer from answers where studentID ='A123456789'";
$result = mysql_query($query,$connection) or die(mysql_error());
$count=0;
while($row = mysql_fetch_assoc($result));
{
$count++;
}
echo $count;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.