You are here: php not recognizing array « PHP Programming Language « IT news, forums, messages
php not recognizing array

Posted by thecoolone on 01/14/07 13:22

I am trying to loop through a mysql result array with the following
code:

while($count = mysql_fetch_assoc($result))
{
$var1=array();
$var1=$count["files"];
$var2=array_slice($var1, 5, -1);
print_r("$var2");
print "<br>";
if(in_array("7194", $var2))
{print "7194 was there in the string so increment counter"; print
"<br>";}
}

For some strange reason php doesnt seem to recognize the result from
mysql_fetch_assoc
as an array and throws the following two error:
Warning: in_array() [function.in-array]: Wrong datatype for second
argument
Warning: array_slice() [function.array-slice]: The first argument
should be an array

is there any syntatic mistake somewhere??
somehow when i just do the foll it prints the array

while($count = mysql_fetch_assoc($result))
{
$var1[]=$count["files"]; // $var1[]
$var2=array_slice($var1, 5, -1);
print_r("$var2");
print "<br>"; }

why is var[] strangely working and var=array() not??

 

Navigation:

[Reply to this 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

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