Re: numeric string to single digit array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




----- Original Message -----
From: Evert Lammerts <evert.lammerts@xxxxxxxxx>
Date: Wednesday, March 26, 2008 3:12 pm
Subject: Re:  numeric string to single digit array

> 
> > I ran this
> >
> > $query ="Select answer from answers where studentID ='A123456789'";
> > $result = mysql_query($query,$connection);
> > $resultArray = str_split($result,1);
> > $count = count($resultArray);
> >   
> 
> Where's the fetch?
> 
> |$result = mysql_query("SELECT answer FROM answers WHERE studentID 
> = 
> 'A123456789';");
> $count = 0;
> while ($row = mysql_fetch_assoc($result)) {
>    $count++;
> }
> 
> |Of course you should count in the query if the result itself is 
> not used:
> 
> |$result = mysql_query("SELECT COUNT(answer) AS nr_of_results FROM 
> answers WHERE studentID = 'A123456789';");
> $row = mysql_fetch_assoc($result);
> $count = $row['||nr_of_results||'];||
> |
> Evert
> 

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;



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux