![]() |
|||
PHP
IT Tags
sdf Solr XML include indexing solr Remove Duplicate mysql server photo gallery ajax control panel SimpleXML Mobile site UPDATE Stop Script my_thread_global_end magento ecommerce Xampp Combo box associative arrays local server objects local server XHTML check domain connection to MYSQL PHP and FLash multiple file uplo php mail server shutdown Simplexml Parser Overlapping Layers |
associative arrays - classes - functions
By: Manoj | 22 Sep 2008 2:17 pm
My main script ============ ========= =======
$result = new questions();
$result->ShortListC ategories( $lang);
$temp="";
$test=explode( "",$result) ;
ksort($test) ;
reset($test) ;
foreach ($test as $ab=>$ac){
$temp.="<OPTION VALUE=\"$ab\ ">$ac\n";
}
============ ========= ========= ==
everything before $temp=""; is working fine :)
ive added / re-added / changed the rest of the code a dozen times-
trying to get it to work...
Here is the function :-
============ ========= ========= ========
Function ShortListCategories ($lan) {
$query = "SELECT category_id, category_name FROM categories ORDER BY
category_id" ;
$result=mysql_ query($query) or die(mysql_error( ));
global $categories;
while ($row = mysql_fetch_ array($result) ) {
$temp=trim($ row[0]);
$categories[ $temp]=trim( $row[1]);
}
reset($categories) ;
return ($categories) ;
}
============ ========= ========= =========
everyting after (& including) global $categories; Ive added / re-
added & changed the codse a dozen times - & nothing works...
Basically, WITHIN the function - I can loop / read / view the
$categories array - & everything works fine - So i KNOW the data is
being stored correctly...
However, No matter what i do, I cannot "return" this/these value(s)
back to the main script...
my "latest" error message is -
Object of class questions could not be converted to string in (main
script file) etc....
Is it possible to retrieve the value from the function - & how ?
PS, Ive found lots of online tutorials - where the function is
includedin the *same* file as the main script.. - But hardly / not
enough examples - where the function is in a class - held in a
different file to the main script... - Unless the example is
$test=5; return $test; etc (very basic script - I find)
Thanks Comments
$result->ShortListC ategories( $lang);
Function ShortListCategories ($lan) { ------------ --------- --------- - I'm not too sure, but I noticed the parameter sent to the function was "$lang", but the one that the function takes to use is "$lan" Hopefully, the problem is just that typo...
By: Admin | 22 Sep 2008
|
