Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 01-23-2010, 09:24 PM Error Message
Average Talker

Posts: 27
Name: Steve
Trades: 0
I am receiving the following error from a Joomla plugin (Rokkin Gallery) and can not seem to get any help from the developer.

Warning: Division by zero in /home/rugby/public_html/components/com_rokin/extensions/ext_rokin_photo.php on line 18

How do I fix this??
__________________
SR Design Concepts
Steve Rosenthal

Please login or register to view this content. Registration is FREE
srdesign is offline
Reply With Quote
View Public Profile Visit srdesign's homepage!
 
 
Register now for full access!
Old 01-23-2010, 10:16 PM Re: Error Message
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Stop dividing by zero. If you want more help, we'll need to see the code.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 01-23-2010, 10:17 PM Re: Error Message
GrooN's Avatar
Average Talker

Posts: 21
Trades: 0
This is not that hard.
As I see you have been trying to divide by zero. To change this you can ex. try to use an 'if' expression on the parameters

But try to link your ext_rokin_photo.php file, and I'll try to fix it if you want ^^

Last edited by GrooN; 01-23-2010 at 10:18 PM..
GrooN is offline
Reply With Quote
View Public Profile
 
Old 01-24-2010, 12:59 AM Re: Error Message
Novice Talker

Posts: 5
Trades: 0
Yep, dividing by zero is actually runtime error.
solomon2 is offline
Reply With Quote
View Public Profile
 
Old 01-26-2010, 10:47 PM Re: Error Message
Average Talker

Posts: 27
Name: Steve
Trades: 0
Sorry...here's the code:

<?php
if(!(defined('_VALID_MOS') || defined( '_JEXEC' ))){
die( 'Restricted access' );
}

/* simple xml for php4 */
$simpe_xml_native =true;
if(!function_exists("simplexml_load_file")){
require_once "administrator/components/com_pwframework/classes/class.simplexml.php";
function simplexml_load_file($file){
$sx = new simplexml;
return $sx->xml_load_file($file);
}
$simpe_xml_native =false;
}


/* make this configurabel */
require_once("administrator/components/com_pwframework/lib/joomla.support.php");

require_once("administrator/components/com_rokin/lib/rokin.common.php");
loadFrameWork();
require_once("administrator/components/com_rokin/lib/classdef.php");
require_once 'administrator/components/com_rokin/lib/classloader.php';
require_once 'administrator/components/com_rokin/lib/picasa_api.php';

//get the correct class file
if(isJoomlaOne()){
require_once("administrator/components/com_rokin/rokin.j10.class.php");
}else{
require_once("administrator/components/com_rokin/rokin.j15.class.php");
}


/*================================================= ========================= */
?>

<style>
table .pw-template{
width: 100%;
}
table .pw-template td{
/*border:1px solid #cccccc;*/

border-spacing: 2px;
}
</style>

<?php
/* loading the rokin specific settings */
$database = getDBase();
$setting = new rokinSetting($database);
$setting->loadById(1);

if(isset($setting->description)){
echo "<p>" . $setting->description ."</p>";
}

$command = new crudcommand();
$GLOBALS['command'] = $command;
$command->optionUrlTag = "unit";
$command->actionUrlTag = "act";
$command->preNavUrl = "index1.php?option=com_rokin&Itemid=" . getReqParamVal('Itemid');
$command->newCommand("gallery", new commandAction("show","Gallery", -1, null, array("Itemid","gid")));
$command->newCommand("album", new commandAction("show","Album", -1, null, array("Itemid","albumid")));
$command->newCommand("photo", new commandAction("show","Photo", -1, null, array("Itemdid","albumid","photoid","photoindex")) );


$rokinRequest = get_rokin_request();
plugins_pre();

echo "<table cellpadding=\"1\" cellspacing=\"1\" class=\"pw-template\" >";

$extensionsTopMost = get_active_subs_per_position(POSITION_TOP_MOST, $rokinRequest->stage);
$extensionsTop = get_active_subs_per_position(POSITION_TOP, $rokinRequest->stage);
$extensionsLeft = get_active_subs_per_position(POSITION_LEFT, $rokinRequest->stage);
$extensionsRight = get_active_subs_per_position(POSITION_RIGHT, $rokinRequest->stage);
$extensionsBottom = get_active_subs_per_position(POSITION_BOTTOM, $rokinRequest->stage);
$extensionsBottomMost = get_active_subs_per_position(POSITION_BOTTOMMOST, $rokinRequest->stage);
$colspan = 1;
if(count($extensionsLeft) > 0){
$colspan++;
}
if(count($extensionsRight) > 0){
$colspan++;
}

if(count($extensionsTopMost)> 0){
echo "<tr><td colspan=\"$colspan\">";
foreach ($extensionsTopMost as $ext){
$ext->render($rokinRequest);
}
echo "</td></tr>";
}


if(count($extensionsTop)> 0){
echo "<tr><td colspan=\"$colspan\">";
foreach ($extensionsTop as $ext){
$ext->render($rokinRequest);
}
echo "</td></tr>";
}

if(count($extensionsLeft)> 0){
echo "<td valign=\"top\">";
foreach ($extensionsLeft as $ext){
$ext->render($rokinRequest);
}
echo "</td>";
}


echo "<td>";

// print_r($command);
// echo "<hr>";
// global $command; //reload from globals (php4 hack)
// print_r($command);
// echo $_REQUEST['unit'];
$command->run();
echo "</td>";

if(count($extensionsRight)> 0){
echo "<td valign=\"top\">";
foreach ($extensionsRight as $ext){
$ext->render($rokinRequest);
}
echo "</td></tr>";
}

if(count($extensionsBottom)> 0){
echo "<tr><td colspan=\"$colspan\">";
foreach ($extensionsBottom as $ext){
$ext->render($rokinRequest);
}
echo "</td></tr>";
}

if(count($extensionsBottomMost)> 0){
echo "<tr><td colspan=\"$colspan\">";
foreach ($extensionsBottomMost as $ext){
$ext->render($rokinRequest);
}
echo "</td></tr>";
}
echo "<tr><td colspan=\"$colspan\" >";
//echo "<span ><a style='font-size:6pt; margin-left; margin-right;color:#cccccc;' href='http://www.pageworks.nl'>PageWorks - RokinWeb Gallery ". getRokinVersion() . "</a></span>";
echo "</td></tr></table>";

plugins_post();


function plugins_pre(){
$rokinRequest = get_rokin_request();
$ext = get_plugings();
foreach ($ext as $e){
$e->renderPre($rokinRequest);
}
}
function plugins_post(){
$rokinRequest = get_rokin_request();
$ext = get_plugings();
foreach ($ext as $e){
$e->renderPost($rokinRequest);
}
}

/**
* initialisation function of the framework called as default
*
*/
function init(){
$Itemid = getReqParamVal("Itemid");
$Itemid = getReqParamVal("gid");
gallery_show($Itemid);
}


/* exectues the active gallery extension */
function gallery_show($Itemid, $gid=null){
$rokinRequest = get_rokin_request();
$ext = get_active_extension_per_stage(STAGE_GALLERY, STAGE_TYPE_EXT);
$ext[0]->render($rokinRequest);
}

/* exectues the active album extension */
function album_show($Itemid, $albumid){
$rokinRequest = get_rokin_request();
$ext = get_active_extension_per_stage(STAGE_ALBUM, STAGE_TYPE_EXT);
$ext[0]->render($rokinRequest);
}

/* executes the active photo extension */
function photo_show($Itemid, $albumid, $photoid){
$rokinRequest = get_rokin_request();
$ext = get_active_extension_per_stage(STAGE_PHOTO, STAGE_TYPE_EXT);
$ext[0]->render($rokinRequest);
}


?>
__________________
SR Design Concepts
Steve Rosenthal

Please login or register to view this content. Registration is FREE
srdesign is offline
Reply With Quote
View Public Profile Visit srdesign's homepage!
 
Old 01-27-2010, 04:48 AM Re: Error Message
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
That code doesn't say much -.-
The error occurs in the file ext_rokin_photo.php, on line 18. Could you post that file? Or if it's big, just a couple of lines (line 18 included of course).
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 01-27-2010, 08:39 AM Re: Error Message
GrooN's Avatar
Average Talker

Posts: 21
Trades: 0
Yea, and can you please mark the text as php. Makes it easier to read ^^
__________________
- GrooN

Please login or register to view this content. Registration is FREE
GrooN is offline
Reply With Quote
View Public Profile
 
Old 01-27-2010, 03:19 PM Re: Error Message
Average Talker

Posts: 27
Name: Steve
Trades: 0
Sorry about the previous code post. Too many hours in front of the monitor..Here's the real deal!

PHP Code:
<?php

if(!(defined('_VALID_MOS') || defined'_JEXEC' ))){
    die( 
'Restricted access' );
}

class 
ext_rokin_photo extends RokinStage{
    
function 
render($rokinRequest){
    
/*load settings*/
    
$database getDBase();
    
$setting $this->loadSettings();
    
$imgmax getImageMax($setting->picture_size);

    
$item $rokinRequest->photo;
    
    
/* load the selected item */
    
$ratio $item->img_width $item->img_height;
    
    
/* load gallery to retrieve sorting order */
    
$gallery $rokinRequest->gallery;
    
    
/* determine next and previous */
    
$items load_rokin_album_items2($rokinRequest->albumid$gallery->order);
    
$total_pictures count($items);
    for(
$i 0$i $total_pictures$i++){
        
/* found, select next and previous */
        
if($items[$i]->id_base==$rokinRequest->photoid){
            if(
$i==0){
                
$prev $total_pictures -1;                
            }else{
                
$prev $i 1;
            }
            if(
$i== ($total_pictures -1)){
                
$next 0;
            }else{
                
$next $i 1;
            }        
            break;    
        }
    }
    
    if(
isDebug()){
        echo 
"next<br>";
        
print_r($items[$next]);
        echo 
"prev<br>";
        
print_r($items[$prev]);
    }
    
    
/* cast to rokinitems */
    
$next_item = new RokinItem($database);
    
$next_item->cast($items[$next]);

    
$prev_item = new RokinItem($database);
    
$prev_item->cast($items[$prev]);
    
//    echo $ratio;
    
if($item->img_width $item->img_height){
        
$height $setting->picture_size $ratio;
    }else{
        
$height $setting->picture_size;
    }
    
?>
    <table cellpadding="0" cellspacing="0"  class="album-detail" style="width:100%; margin:10px;">
        <tr><td></td><td align="center" style="text-align:center;"><div style="line-height:20px; color:white; font-weight: bold; font-size: 110%;padding-top:4px;"> <?php  echo ($i 1) . " / " $total_pictures ?></div></td><td></td></tr>
        <tr>
            <td width="70" align="center">                
                <a href="<?php echo $prev_item->getUrlForPhotoid($rokinRequest->Itemid); ?>">
                    <img src="<?php echo $this->extension_url?>/images/prev.gif" border="0">
                </a>
            </td>
            <td align="center" style="text-align: center;">
                <img src="<?php echo $item->img_base;?>?imgmax=<?php echo $imgmax;?>" height="<?php echo $height?>" title="<?php echo $this->title?>"  class="pwimages" border="0" />
            </td>
            <td width="70" align="center">
                <a href="<?php echo $next_item->getUrlForPhotoid($rokinRequest->Itemid); ?>">
                    <img src="<?php echo $this->extension_url?>/images/next.gif"  border="0">
                </a>
            </td>
        </tr>
    </table>
    <?php
 
}
      

    
/**
     * this function renders the settings when you configure the extension
     *
     */
    
function renderSettings($lang){
        
$classLoader = new RokinClassLoader();
        
$setting $this->loadSettings();
        
$myForm1 = new Composite();    
        
$myForm1->value=$lang->gallery_settings;
        
$myForm1->addElement(new JoomlaLabel($lang->picture_size""),new InputText("picture_size",  $setting->picture_size"picture_size"));
        
$myForm1->render();    
    }
    function 
storeSettings(){
        
parent::storeSettings(array("picture_size"));
    }
    
    function 
loadSettings(){
        return 
parent::loadSettings(array("picture_size=640"));
    }
}
?>
__________________
SR Design Concepts
Steve Rosenthal

Please login or register to view this content. Registration is FREE

Last edited by chrishirst; 01-27-2010 at 03:26 PM.. Reason: Added CODE tags
srdesign is offline
Reply With Quote
View Public Profile Visit srdesign's homepage!
 
Old 01-27-2010, 03:27 PM Re: Error Message
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by GrooN View Post
Yea, and can you please mark the text as php. Makes it easier to read ^^
Here's how!
http://www.webmaster-talk.com/php-fo...st-my-php.html
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-27-2010, 03:29 PM Re: Error Message
GrooN's Avatar
Average Talker

Posts: 21
Trades: 0
The problem is on line 18 as the error writes ^^

heres a fix for it:

PHP Code:
if ($item->img_height 0// Checking that the img_height isn't zero
    
$ratio $item->img_width $item->img_height;
else 
// if the img_height is zero
    
somefunction_error_handling("divide by zero"); // function i made up, does not exist! 
I think the comments speak for themselves ^^
__________________
- GrooN

Please login or register to view this content. Registration is FREE

Last edited by GrooN; 01-27-2010 at 03:30 PM..
GrooN is offline
Reply With Quote
View Public Profile
 
Old 01-28-2010, 09:45 AM Re: Error Message
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Been busy as all **** for a few days, so just now catching up, and doing some traveling the next few weeks...

As a suggestion, you may want to handle this better when fetching the image information:

PHP Code:
$rokinRequest->photo 
That bit of code is returning a zero value for img_height, so you'd actually do better to have some error checking wherever that attribute is defined... a try/catch routine where the image must exist and have a width and height each > 0. This will catch the error you'll find of dividing by $ratio when the width is 0.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Reply     « Reply to Error Message
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.50233 seconds with 12 queries