4images Forum & Community

General / Allgemeines => Programming => Topic started by: MrAndrew on February 26, 2011, 12:51:29 PM

Title: Very strange and unknown error
Post by: MrAndrew on February 26, 2011, 12:51:29 PM
Please help me resolve this problem, i don`t understand what is the problem! I`ve this code in file msweek.php

<?php

$time = time() - 60 * 60 * 24 * 7;
$sql = "SELECT COUNT(*) AS num_rows_all
        FROM (" . IMAGES_TABLE . " i, " . CATEGORIES_TABLE . " c)
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.image_date >= " . $time . " AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")
        ";
        
$row = $site_db->query_firstrow($sql);
$num_rows_all = (isset($row['num_rows_all'])) ? $row['num_rows_all'] : 0;

$link_arg = $site_sess->url(ROOT_PATH."index.php");

$imgtable_width = ceil(intval($config['image_table_width']) / $config['image_cells']);
if ((substr($config['image_table_width'], -1)) == "%") {
  $imgtable_width .= "%";
}

$additional_sql = "";
if (!empty($additional_image_fields)) {
  foreach ($additional_image_fields as $key => $val) {
    $additional_sql .= ", i.".$key;
  }
}

$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
        FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.image_date >= " . $time . " AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")
        ORDER BY i.image_hits DESC
        LIMIT 2";
        
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

if (!$num_rows)  {
  $msweek_new_images = "<table align=\"center\" width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
  $msweek_new_images .= $lang['no_today_images'];
  $msweek_new_images .= "</td></tr></table>";
}
else  {
  $msweek_new_images = "<table align=\"center\" width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
  $count = 0;
  $bgcounter = 0;
  while ($image_row = $site_db->fetch_array($result)) {
    if ($count == 0) {
      $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;

    }
    $msweek_new_images .= "<td width=\"".$imgtable_width."\" align=\"center\" >\n";

    show_image($image_row);
    $msweek_new_images .= $site_template->parse_template("most_rated_bit");
    $msweek_new_images .= "\n</td>\n";
    $count++;
    if ($count == $config['image_cells']) {

      $count = 0;
    }
  } // end while

  if ($count > 0)  {
    $leftover = ($config['image_cells'] - $count);
    if ($leftover >= 1) {
      for ($f = 0; $f < $leftover; $f++) {

      }
      $msweek_new_images .= "</tr>\n";
    }
  }
  $msweek_new_images .= "</table>\n";
}  // end else

$site_template->register_vars("msweek_images", $msweek_new_images);
unset($msweek_new_images);
?>

And add this path to index.php

include(ROOT_PATH.'msweek.php');

But i have error:

Fatal error: Call to a member function url() on a non-object in /home/users2/m/***/domains/***/msweek.php on line 12

Line 12 is:

$link_arg = $site_sess->url(ROOT_PATH."index.php");

Version of the gallery 1.7.9, on my first site it work fine!

In what file maybe problem?

Thanks!

Title: Re: Very strange and unknown error
Post by: Rembrandt on February 26, 2011, 01:19:09 PM
hm.. for me work it, but you can try this:
insert below
Code: [Select]
<?phpthis
Code: [Select]
global $site_sess;
mfg Andi
Title: Re: Very strange and unknown error
Post by: MrAndrew on February 26, 2011, 01:38:37 PM
Code: [Select]
Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE or '$' in /home/users2/m/milan/domains/planesphotos.net/msweek.php on line 2
:-(
Title: Re: Very strange and unknown error
Post by: Rembrandt on February 26, 2011, 04:17:06 PM
oups  :oops: i have edit my frist post.
Title: Re: Very strange and unknown error
Post by: MrAndrew on February 26, 2011, 05:32:44 PM
Code: [Select]
Fatal error: Call to a member function url() on a non-object in /home/users2/m/milan/domains/planesphotos.net/msweek.php on line 13
Nothing :-(
Title: Re: Very strange and unknown error
Post by: Rembrandt on February 26, 2011, 05:37:32 PM
i understand this not , i have no error.
in the index.php, where you add the "include" ?
Title: Re: Very strange and unknown error
Post by: MrAndrew on February 26, 2011, 06:11:52 PM
In the first part of file:

$templates_used = 'home,category_bit,whos_online,thumbnail_bit,thumbnail2_bit';
$main_template = 'home';

define('GET_CACHES', 1);
define('ROOT_PATH', './');
define('MAIN_SCRIPT', __FILE__);
define('GET_USER_ONLINE', 1);
include(ROOT_PATH.'global.php');
include(ROOT_PATH.'msweek.php');

require(ROOT_PATH.'includes/sessions.php');
Title: Re: Very strange and unknown error
Post by: Rembrandt on February 26, 2011, 07:37:25 PM
you must include below:
require(ROOT_PATH.'includes/sessions.php');

and this can you remove:
global $site_sess;
Title: Re: Very strange and unknown error
Post by: MrAndrew on February 26, 2011, 07:45:03 PM
What a .**** I`ve edited this within a 3-4 days :-) Screw my mind!!! Really thanks!!!