Reply to newbie: problem with mysql_fetch_array

Your name:

Reply:


Posted by deko on 06/09/06 09:50

I'm trying to select a few rows:

$db = mysql_connect('localhost','userID','passwd');
if ($db)
{
$sql = "select cat_ID, cat_name from categories where category_count > 0";
mysql_select_db('dbName');
$result = mysql_query($sql);
$arrayCat = mysql_fetch_array($result);
}
mysql_close;

echo count($arrayCat); //count = 4

foreach ($arrayCat as $cat)
{
// this will iterate 4 times
echo "<br>".$arrayCat["cat_ID"]; // = 1
echo "<br>".$arrayCat["cat_name"]; // = test
}

what I don't understand is I get an array count of 4, but if I look in the
table, I see only 3 rows that meet the select criteria. Furthermore, why does
each iteration echo the same thing:

1
test
1
test
1
test
1
test

Am I using mysql_fetch_array wrong?

Thanks in advance.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация