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

2008-03-26 Thread Richard Dunne
- Original Message - From: Chris [EMAIL PROTECTED] Date: Wednesday, March 26, 2008 2:18 am Subject: Re: [PHP-DB] numeric string to single digit array Richard Dunne wrote: Sorry for the top-posting, it's my mail client, not my design. I honestly have not even looked at myphpadmin

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

2008-03-26 Thread Evert Lammerts
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 =

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

2008-03-26 Thread Richard Dunne
- Original Message - From: Evert Lammerts [EMAIL PROTECTED] Date: Wednesday, March 26, 2008 3:12 pm Subject: Re: [PHP-DB] numeric string to single digit array I ran this $query =Select answer from answers where studentID ='A123456789'; $result = mysql_query($query,$connection

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

2008-03-26 Thread Richard Dunne
- Original Message - From: Evert Lammerts [EMAIL PROTECTED] Date: Wednesday, March 26, 2008 3:39 pm Subject: Re: [PHP-DB] 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

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

2008-03-26 Thread Evert Lammerts
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

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

2008-03-26 Thread Evert Lammerts
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

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

2008-03-26 Thread Jason Gerfen
Evert Lammerts wrote: 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'

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

2008-03-26 Thread Richard Dunne
- Original Message - From: Evert Lammerts [EMAIL PROTECTED] Date: Wednesday, March 26, 2008 4:04 pm Subject: Re: [PHP-DB] numeric string to single digit array This is my code. The only error is at line 15 as I stated above. 1 ?PHP 2 DEFINE (host,localhost); 3 DEFINE (user

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

2008-03-26 Thread Evert Lammerts
OK. Tried that and count comes back as 1. So your query returns only one record. Try $query =Select answer from answers; -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

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

2008-03-26 Thread Jeremy Mcentire
On Mar 26, 2008, at 12:30 PM, Evert Lammerts wrote: OK. Tried that and count comes back as 1. So your query returns only one record. Try $query =Select answer from answers; Why not do a var_dump() on $result to verify that it is a mysql result resource and then verify the count of rows

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

2008-03-26 Thread Richard Dunne
- Original Message - From: Evert Lammerts [EMAIL PROTECTED] Date: Wednesday, March 26, 2008 4:30 pm Subject: Re: [PHP-DB] numeric string to single digit array OK. Tried that and count comes back as 1. So your query returns only one record. Try $query =Select answer

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

2008-03-26 Thread Evert Lammerts
Tried that as well and got the same result. I tried Select count(answer) as total from answers where studentID='A123456789'; from the CLI and got total = 2 as a result. So, we got rid of the Invalid Resource error and we know that the student id you use occurs in both rows in your table

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

2008-03-26 Thread Richard Dunne
- Original Message - From: Evert Lammerts [EMAIL PROTECTED] Date: Wednesday, March 26, 2008 5:22 pm Subject: Re: [PHP-DB] numeric string to single digit array Tried that as well and got the same result. I tried Select count(answer) as total from answers where studentID

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

2008-03-26 Thread Richard Dunne
Using this extract from http://ie.php.net/manual/en/control-structures.foreach.php Amaroq 09-Mar-2008 06:40 Even if an array has only one value, it is still an array and foreach will run it. ?php $arr[] = I'm an array.; if(is_array($arr)) { foreach($arr as $val) { echo $val;

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

2008-03-26 Thread Jon L.
not getting any output. Has anyone got a better idea? -- Forwarded message -- From: Evert Lammerts [EMAIL PROTECTED] To: Richard Dunne [EMAIL PROTECTED] Date: Wed, 26 Mar 2008 18:22:53 +0100 Subject: Re: [PHP-DB] numeric string to single digit array Tried that as well and got

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

2008-03-26 Thread Chris
Richard Dunne wrote: Using this extract from http://ie.php.net/manual/en/control-structures.foreach.php Amaroq 09-Mar-2008 06:40 Even if an array has only one value, it is still an array and foreach will run it. ?php $arr[] = I'm an array.; if(is_array($arr)) { foreach($arr as $val)

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

2008-03-26 Thread Richard Dunne
I did var_dump on the result resource and I got resource(5) of type (mysql result). ---BeginMessage--- On Mar 26, 2008, at 12:30 PM, Evert Lammerts wrote: OK. Tried that and count comes back as 1. So your query returns only one record. Try $query =Select answer from answers; Why not

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

2008-03-25 Thread Chris
Richard Dunne wrote: Can anyone tell me how how to convert a string of integers into an array of single digit integers. i.e. 1223123 into ['1','2,','2','3','1,'2','3'] ? $string = '12345'; $array = array(); for ($i = 0; $i strlen($string); $i++) { $array[] = $string[$i]; } I'm sure

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

2008-03-25 Thread Chris
Please always CC the mailing list so others can learn and also contribute answers. Also please don't top-post as it makes it hard to follow discussions. Richard Dunne wrote: I am using MySQL and retrieving a single column which consists of single digit integers. I have been doing a lot of

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

2008-03-25 Thread Richard Dunne
Sorry for the top-posting, it's my mail client, not my design. I honestly have not even looked at myphpadmin much, using the CLI mostly. - Original Message - From: Chris [EMAIL PROTECTED] Date: Wednesday, March 26, 2008 0:53 am Subject: Re: [PHP-DB] numeric string to single digit

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

2008-03-25 Thread Chris
Richard Dunne wrote: Sorry for the top-posting, it's my mail client, not my design. I honestly have not even looked at myphpadmin much, using the CLI mostly. It's easy enough to click to another place in your mail client ;) So what happens when you run that query manually? -- Postgresql