Jump to content

[SOLVED] Need help with code


mmckimson

Recommended Posts

I am a PHP novice and have downloaded and installed a rather nifty free PHP application for handling affiliates on my ecommerce site for which the developer offers zero support.  Every piece of the code works as I would expect it to, except for the commission-details.php file which is displaying a blank screen instead of the data (that somehow seems to work on the developer's demo website).

 

I have looked at the code and see no obvious errors, but don't really know how to fix this.  If someone would be willing to look at the attached zip file and help me unravel the mystery in the commission-details.php code which is located in the root directory, it would be much appreciated.

 

ike

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/173900-solved-need-help-with-code/
Share on other sites

OK, I added this suggestion to the top of the code, and the page is still displaying a blank page.  Here is the code from the commission-details.php page that is displaying as a blank:

 

error_reporting(E_ALL);

 

$gProtected = TRUE;

 

require_once('header.php');

 

$com_id = (INT)$_GET['id']; // id commission

 

if(!$com_id)

{

$items = (int)$_GET['items'];

$items = $items ? $items : 5 ;

 

define(ITEMS_PER_PAGE, $items);

 

$page = (int)$_GET['page'];

$page = ($page < 1) ? 1 : $page;

$start = ($page - 1) * ITEMS_PER_PAGE;

 

$ctype = $_GET['type'];

if(!$ctype)

$ctype = 'pending';

 

switch($ctype)

{

case 'pending':

$commissions = $gXpDb->getCommissionsByStatus($aff['id'], 1, $start, ITEMS_PER_PAGE);

$total = $gXpDb->getCommissionsByStatus(0);

$url = "commission-details.php?type=pending";

break;

case 'approved':

$commissions = $gXpDb->getCommissionsByStatus($aff['id'], 2, $start, ITEMS_PER_PAGE);

$total = $gXpDb->getCommissionsByStatus(2);

$url = "commission-details.php?type=approved";

break;

//case 'paid': $commissions = $gXpDb->getPaidCommissions();

}

 

$title = $gXpLang['site_title'].' - '.$gXpLang['commission_details'];

 

$navigation = navigation(count($total), $start, count($commissions), $url, ITEMS_PER_PAGE);

 

$gXpSmarty->assign_by_ref('commissions', $commissions);

$gXpSmarty->assign_by_ref('navigation', $navigation);

$gXpSmarty->assign_by_ref('ctype', $ctype);

}

elseif($com_id > 0 && is_array($aff) and $aff['id']>0)

{

$percent = $gXpConfig['payout_percent']/100;

$commission = $gXpDb->getCommissionsById($aff['id'], $com_id);

$gXpSmarty->assign_by_ref('percent', $percent);

$gXpSmarty->assign_by_ref('commission', $commission);

}

 

$description = $gXpLang['desc_commission_details'];

$keywords = $gXpLang['keyword_commission_details'];

 

$gXpSmarty->assign_by_ref('description', $description);

$gXpSmarty->assign_by_ref('keywords', $keywords);

$gXpSmarty->assign_by_ref('title', $title);

 

$gXpSmarty->display("commission-details.tpl");

 

?>

 

Here is the related commission-details.tpl file:

 

{include file="header.tpl"}

 

<h2>{$lang.commission_details}</h2>

{if $commission.id eq '' && $smarty.get.id eq ''}

{if $aff.approved eq 2}

<div style="font-size: 13px;">

<ul class="options">

<li>{$lang.commissions}: </li>

<li>

{if ($ctype!="pending")}

<a href="commission-details.php?type=pending" style="font-size: 13px;">{$lang.pending_approval}</a>

{else}

<b>{$lang.pending_approval}</b>

{/if}

</li>

<li>

{if ($ctype!="approved")}

<a href="commission-details.php?type=approved" style="font-size: 13px;">{$lang.approved}</a>

{else}

<b>{$lang.approved}</b>

{/if}

</li>

<!-- <li>

{if ($ctype!="paid")}

<a href="commission-details.php?type=paid" style="font-size: 13px;">Paid</a>

{else}

<b>Paid</b>

{/if}

</li>

-->

</ul>

 

<div style="clear: both;"></div>

 

<table cellpadding="0" cellspacing="0" style="margin-top: 10px; width: 100%;">

<tr style="font-weight: bold;">

<td>{$lang.sale_date}</td>

<td>{$lang.status}</td>

<td>{$lang.sale_amount}</td>

<td>{$lang.action}</td>

</tr>

{foreach from=$commissions item=commission}

<tr>

<td>{$commission.date}</td>

<td>{if $commission.approved}{$lang.approved}{else}{$lang.pending}{/if}</td>

<td>{$commission.payment}</td>

<td><a href="commission-details.php?{if $smarty.get.type}type={$smarty.get.type}&{/if}{if $smarty.get.page}page={$smarty.get.page}&{/if}{if $smarty.get.items}items={$smarty.get.items}&{/if}id={$commission.id}" >{$lang.small_view_details}</a></td>

</tr>

{/foreach}

</table>

<br />

{$navigation}

</div>

{else}

<strong>{$lang.msg_account_pending_approval}</strong>

{/if}

{elseif $commission.id > 0}

<a href="commission-details.php?{if $smarty.get.type}type={$smarty.get.type}&{/if}{if $smarty.get.page}page={$smarty.get.page}&{/if}{if $smarty.get.items}items={$smarty.get.items}{/if}">{$lang.return_go_back}</a><br />

<br />

<table border="0" cellspacing="1" cellpadding="0" bgcolor="#CCCCCC" width="100%">

<tr>

<td width="150" bgcolor="#FFFFFF" style="padding: 2px 10px;" align="right"><strong>{$lang.sale_date}</strong></td>

<td bgcolor="#FFFFFF" style="padding: 2px 10px;">{$commission.date} {$commission.time}</td>

</tr>

<tr>

<td bgcolor="#FFFFFF" style="padding: 2px 10px;" align="right"><strong>{$lang.sale_amount}</strong></td>

<td bgcolor="#FFFFFF" style="padding: 2px 10px;">{$commission.payment}</td>

</tr>

<tr>

<td bgcolor="#FFFFFF" style="padding: 2px 10px;" align="right"><strong>{$lang.commissions}</strong></td>

<td bgcolor="#FFFFFF" style="padding: 2px 10px;">{$commission.payment*$percent}</td>

</tr>

<tr>

<td bgcolor="#FFFFFF" style="padding: 2px 10px;" align="right"><strong>{$lang.order_number}</strong></td>

<td bgcolor="#FFFFFF" style="padding: 2px 10px;">{$commission.order_number}</td>

</tr>

</table>

{elseif $smarty.get.id > 0}

<strong style="color: #FF0000">{$lang.msh_incorrect_param}</strong>

{/if}

{include file="footer.tpl"}

 

 

With respect to error reporting, is there anything else I need to do?

Mike

 

 

Yipee.  You folks are geniuses...

 

When I inserted the error checking, while there were some immaterial errors shown, the smarty module was unable to read the resource commission-details.tpl.  Why?  Because the developer had misspelled it comission-details.tpl.  As soon as I renamed the file, it worked fine!

 

Thanks so much.

Mike

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.