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:39 pm
Subject: Re:  numeric string to single digit array

> 
> > 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;
> 
This is my code.  The only error is at line 15 as I stated above.

1 <?PHP
2 DEFINE ("host","localhost");
3 DEFINE ("user","root");
4 DEFINE ("password","password");
5 DEFINE ("database","questions");
6
7 $connection=mysql_connect(host,user,password) or die ('Could not connect' .mysql_error() );
8
9 $dbConnect=mysql_select_db('questions',$connection);
10 if (!$dbConnect) {die ('Could not connect to database' . mysql_error() );}
11
12 $query ="Select answer from answers where studentID ='A123456789'";
13 $result = mysql_query($query,$connection);
14 $count=0;
15 while($row = mysql_fetch_assoc($result));
16 {
17 $count++;
18 }
19 echo $count;
20 ?>


-- 
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