b1xx1b
asked on
passing function to a function?
Hello, I am trying to pass a function to a function in PHP, but it seems that only the function that is being passed works.
The Value of woo_get_custom_banner('ban nerIDside' ) is 10 and the only thing that shows up on the page is 10 but what SHOULD be showing up is a banner!
if I use
mba_display_banner(10);
the function works perfectly.
any ideas??
The Value of woo_get_custom_banner('ban
if I use
mba_display_banner(10);
the function works perfectly.
any ideas??
<div id="rightbanner">
<?php mba_display_banner(woo_get_custom_banner('bannerIDside')); ?>
</div>
What does mba_display_banner(10) do for you? If it does the same thing as what you posted above, then your problem lies in mba_display_banner.
ASKER
if I use
mba_display_banner(10);
the function works perfectly and correctly displays the banner (with banner_id = 10)
mba_display_banner(10);
the function works perfectly and correctly displays the banner (with banner_id = 10)
Oops.. didn't read the whole thing. Are you absolutely sure woo_get_custom_banner is working correctly?
ASKER
( i edited the post AFTER you commented ... you didn't miss it :))
yes, I am positive the function works perfectly.
yes, I am positive the function works perfectly.
Would you mind sharing both functions?
ASKER
sure here they are:
function mba_display_banner(&$banne r_id) {
global $MBPBannerAdsPlugin;
global $banner_id;
if ( !is_admin() ) {
if ( intval($banner_id) > 0 ) {
$banner_filter = "id='$banner_id'";
} else {
$banner_filter = "name='$banner_id'";
}
$sql = "SELECT id,url,link,in_new_win,ad_ type,text_ ad_code FROM $MBPBannerAdsPlugin->mban_ banner_tab le WHERE status='1' AND {$banner_filter}";
$rs = mysql_query($sql);
$id = array();
$url = array();
$link = array();
$in_new_win = array();
$text_ad_code = array();
$zone_properties = array();
while ( $data = @mysql_fetch_assoc($rs) ) {
$cnt++;
if ( $data['ad_type'] == 1 ) {
$id[] = $data['id'];
$text_ad_code[] = $data['text_ad_code'];
} else {
$id[] = $data['id'];
$url[] = $data['url'];
$link[] = $data['link'];
$in_new_win[] = $data['in_new_win'];
}
}
if ( count($id) > 0 ) {
$banner_output = $MBPBannerAdsPlugin->__mba nGetBanner ($id,$url, $link,$in_ new_win,$z one_proper ties,$text _ad_code);
echo $banner_output;
//echo $sql;
}
}
}
function woo_get_custom_banner($key ) {
global $post;
$custom_field = get_post_meta($post->ID, $key, true);
if ($custom_field) {
$custom_field = stripslashes($custom_field );
?>
<?php echo $custom_field; ?>
<?php
}
else { //else, return
return;
}
}
function mba_display_banner(&$banne
global $MBPBannerAdsPlugin;
global $banner_id;
if ( !is_admin() ) {
if ( intval($banner_id) > 0 ) {
$banner_filter = "id='$banner_id'";
} else {
$banner_filter = "name='$banner_id'";
}
$sql = "SELECT id,url,link,in_new_win,ad_
$rs = mysql_query($sql);
$id = array();
$url = array();
$link = array();
$in_new_win = array();
$text_ad_code = array();
$zone_properties = array();
while ( $data = @mysql_fetch_assoc($rs) ) {
$cnt++;
if ( $data['ad_type'] == 1 ) {
$id[] = $data['id'];
$text_ad_code[] = $data['text_ad_code'];
} else {
$id[] = $data['id'];
$url[] = $data['url'];
$link[] = $data['link'];
$in_new_win[] = $data['in_new_win'];
}
}
if ( count($id) > 0 ) {
$banner_output = $MBPBannerAdsPlugin->__mba
echo $banner_output;
//echo $sql;
}
}
}
function woo_get_custom_banner($key
global $post;
$custom_field = get_post_meta($post->ID, $key, true);
if ($custom_field) {
$custom_field = stripslashes($custom_field
?>
<?php echo $custom_field; ?>
<?php
}
else { //else, return
return;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Note: I have used the function like this:
function mba_display_banner(&$banne r_id)
and with the & like this
function mba_display_banner($banner _id)
and still does not work correctly.
function mba_display_banner(&$banne
and with the & like this
function mba_display_banner($banner
and still does not work correctly.
ASKER
Thanks! That did the trick. duh.