Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- mysql_fetch_array... interesting
October 23, 2004, 1:18 pm
rate this thread
this is probably another simple one, but the web doesnt seem to have an
answer that I can find.
Veeeery simple code. each row has 10 columns.
$query = "SELECT * FROM mytable";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
for($x=0; $x<$numrows; $x++)
$row_arrays[$x] = mysql_fetch_array($result);
//test row 1
foreach($row_arrays as $count)
result for each print is the column number (0-9) and each id(0,a,1,b,2,c
etc). But if I use mysql_fetch_array($result, 'MSQL_ASSOC') as the docs
say, I get the 'The result type should be either MYSQL_NUM, MYSQL_ASSOC or
MYSQL_BOTH' error. No quotes, additional error about undefined constant. I
figure using this would get the array including the id only and not include
the number. Perhaps its the wrong assumption?
- Gabriele Farina *DarkBard*
October 23, 2004, 3:05 pm
Re: mysql_fetch_array... interesting
Hi thanks, yes I tried that as well.
but this morning (I always think better in the late mornings) I used
mysql_fetch_assoc instead and all is good.
However, on the fetch_array method, when I used MYSQL_ASSOC alone (first
way I tried it) I get the undefined constant error. Well ok not an error, a
notice - "PHP Notice: Use of undefined constant MSQL_ASSOC - assumed
'MSQL_ASSOC'"It looks like it doesnt know what this constant is, so its
changing it to a string. Question is why its not identifying the constant.
Academic now but I dont like it when simple functions dont work they way
they are supposed to... just bugs me because I might need it later :-)