- 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
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 =
- 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
- 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
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
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
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'
- 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
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
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
- 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
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
- 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
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;
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
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)
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
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
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
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
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
21 matches
Mail list logo