Jump to content

php errors


numnut3200

Recommended Posts

not used php for along time and know things are diffrent so here goes i got assked into helping a friend with his project and im hooked again but i'm lost with it i got some errors from a session function i think the code is correct maybe for some reason its not being called

 

function value($variable) seams to be the problem

 

Notice: Undefined index: tsts_site_theme in C:\xampp\htdocs\test\includes\class_session.php on line 36

Notice: Undefined index: start in C:\xampp\htdocs\test\includes\init.php on line 90

Warning: html_entity_decode() expects parameter 2 to be long, string given in C:\xampp\htdocs\test\includes\class_database.php on line 410

Notice: Undefined index: tsts_is_seller in C:\xampp\htdocs\test\includes\class_session.php on line 36

Notice: Undefined index: tsts_username_cookie in C:\xampp\htdocs\test\includes\class_session.php on line 71

Notice: Undefined index: tsts_username in C:\xampp\htdocs\test\includes\class_session.php on line 36

Notice: Undefined index: preferred_days in C:\xampp\htdocs\test\cron_jobs\main_cron.php on line 315

Notice: Undefined index: remove_marked_deleted in C:\xampp\htdocs\test\cron_jobs\main_cron.php on line 324

Notice: Undefined index: enable_force_payment in C:\xampp\htdocs\test\cron_jobs\main_cron.php on line 341

Notice: Undefined index: tsts_user_id in C:\xampp\htdocs\test\includes\class_session.php on line 36

class_session.php

Link to comment
Share on other sites

but it has to set because this variable controls the site_theme

Your class deals with $_SESSION and $_COOKIE variables. These variables usually associative arrays, whereby the data you are storing in that variable is assigned a key. This key is then used to retrieve that data associated to it. You cannot presume the keys will always exist.

 

For example when someone logs in to your site you login you may store their username in the session using

$_SESSION['username'] = $username;

and you'd echo their username with

echo $_SESSION['username']; 

the username key will only exist, when the user has logged in. It will not exist if they are not logged in. So you need to check that the username key exists first before using it.

if(isset($_SESSION['username']))
   echo 'Welcome, ' . $_SESSION['username']; // great the logged in user
else
   echo 'Please login in'; // username key does not exist, so user must not be logged in

-------------

 

So, jairathnem is correct that you need to use isset. About four of those notices are referencing line 39

return $_SESSION[SESSION_PREFIX.$variable];

Here you are presuming the key produced by   SESSION_PREFIX.$variable   exists in the $_SESSION array. A simple fix is to us isset

return isset($_SESSION[SESSION_PREFIX.$variable]) ? $_SESSION[SESSION_PREFIX.$variable] : null;

The above code will return the value, if the key exists. If it doesn't it'll return null.

 

Simlarly their is a notice produced for line 71

$cookie_value = $_COOKIE[SESSION_PREFIX.$variable];

Again you're presuming the key produced by   SESSION_PREFIX.$variable  exists in $_COOKIE. A fix would be to check that it exists

if(isset($_COOKIE[SESSION_PREFIX.$variable]))
{
    // do something with cookie value
}

You should now be left with 4 notices, 3 of which are being reported from main_cron.php on line 315, 324 and 341. Again where you are using keys which you presume exists. The fix would be to check that they exist before using them.

 

This will leave you with, one actual error being

 

 

Warning: html_entity_decode() expects parameter 2 to be long, string given in C:\xampp\htdocs\test\includes\class_database.php on line 410

Check what are passing to that function is correct, The data you want decoded should be passed as the first argument. The second argument is for setting the flags, see php.net/html_entity_decode for possible options.

Edited by Ch0cu3r
Link to comment
Share on other sites

ok first thanks for your input ive worked out that the the function is working

 

this class_session.php

	function value($variable)
	{

	return $_SESSION[SESSION_PREFIX.$variable];

	}

will output an array form a table like (english ,sitename ,some settings) i know this works if i echo it ,it is shows the info

 

my problem is the global_header.php is not pick the variables up for example

 

this line include ('themes/'.$setts['default_theme'].'/title.php'); should be themes/theme/title.php

 

insted i get this error  Warning: include(): Failed opening 'themes//title.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\test\global_header.php on line 16

 

i know all other errors are related to this variable array and the function is working because other pages relay on this array and are reciving it

<?php


if ( !defined('INCLUDED') ) { die("Access Denied"); }



$time_start = getmicrotime();
$currentTime = time();

include ('themes/'.$setts['default_theme'].'/title.php');

/* we will add new banner settings */
$banner_position = array();
foreach ($setts['banner_positions'] as $key => $value)
{
	$banner_position[$key] = $site_banner->select_banner($_SERVER['PHP_SELF'], intval($_REQUEST['parent_id']), intval($_REQUEST['auction_id']), $key);
	
	if (!empty($banner_position[$key]))
	{
		$banner_position[$key] = '<div align="center" style="padding-top: 3px; padding-bottom: 3px;">' . $banner_position[$key] . '</div>';
	}
}
$template->set('banner_position', $banner_position);

$template->set('page_file_name', basename($_SERVER['PHP_SELF']));

$meta_tags_details = meta_tags($_SERVER['PHP_SELF'], intval($_REQUEST['parent_id']), intval($_REQUEST['auction_id']), intval($_REQUEST['wanted_ad_id']), intval($_REQUEST['user_id']));
$template->set('page_title', $meta_tags_details['title']);

$page_meta_tags = $meta_tags_details['meta_tags'];

$current_time_display = date("F d, Y H:i:s", time() + (TIME_OFFSET * 3600));
$template->set('current_time_display', $current_time_display);

$page_meta_tags .= $template->process('global_header.tpl.php');

$template->change_path('themes/' . $setts['default_theme'] . '/templates/');

$template->set('page_meta_tags', $page_meta_tags);

$current_date = date(DATE_FORMAT, time() + (TIME_OFFSET * 3600));
$template->set('current_date', $current_date);

if ($setts['user_lang'])
{
	$template->set('languages_list', list_languages('site', false, null, true));
}

$menu_box_header = header7(MSG_MEMBERS_AREA_TITLE . ' [<a title="show/hide" class="hidelayer" id="exp1102170142_link" href="javascript: void(0);" onclick="toggle(this, \'exp1102170142\');">–</a>]');
$template->set('menu_box_header', $menu_box_header);

$category_box_header = headercat(MSG_CATEGORIES . ' [<a title="show/hide" class="hidelayer" id="exp1102170166_link" href="javascript: void(0);" onclick="toggle(this, \'exp1102170166\');">–</a>]');
$template->set('category_box_header', $category_box_header);

(string) $category_box_content = null;

reset($categories_array);

$categories_browse_box = '<select name="parent_id" id="parent_id" class="contentfont" onChange="javascript:cat_browse_form.submit()"> '.
	'<option value="" selected>' . MSG_CHOOSE_CATEGORY . '</option>';

$sql_select_cats_header = $db->query("SELECT category_id, items_counter, hover_title FROM
	" . DB_PREFIX . "categories WHERE parent_id=0 AND hidden=0 AND user_id=0 AND enable_auctions=1 ORDER BY order_id ASC, name ASC");

$template->set('category_lang', $category_lang);

while ($cats_header_details = $db->fetch_array($sql_select_cats_header))
{
	$category_link = process_link('categories', array('category' => $category_lang[$cats_header_details['category_id']], 'parent_id' => $cats_header_details['category_id']));

	$categories_browse_box .= '<option value="' . $cats_header_details['category_id'] . '" ' . (($cats_header_details['category_id'] == $_REQUEST['parent_id']) ? 'selected' : '') . '>'.
		$category_lang[$cats_header_details['category_id']] . '</option> ';

}

$categories_browse_box .= '<option value="">------------------------</option> '.
	'<option value="0">' . MSG_ALL_CATEGORIES . '</option></select>';

// add addThis code
if ($setts['enable_addthis'])
{
	$share_code = '<!-- AddThis Button BEGIN -->
		<a class="addthis_button" href="http://www.addthis.com/bookmark.php?v=250&pub=xa-4a83d52479e9d5ed"><img src="https://s7.addthis.com/static/btn/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0" align="middle" /></a><script type="text/javascript" src="https://s7.addthis.com/js/250/addthis_widget.js?pub=xa-4a83d52479e9d5ed"></script>
		<!-- AddThis Button END -->';	
	$template->set('share_code', $share_code);
}

$template->set('categories_browse_box', $categories_browse_box);

$sql_select_cats_list = $db->query("SELECT category_id, items_counter, hover_title FROM
	" . DB_PREFIX . "categories WHERE parent_id=0 AND hidden=0 AND user_id=0 AND enable_auctions=1 ORDER BY order_id ASC, name ASC");

$template->set('sql_select_cats_list', $sql_select_cats_list);

$category_box_content = $template->process('header_categories_box.tpl.php');
$template->set('category_box_content', $category_box_content);

(string) $menu_box_content = NULL;

if (!$session->value('user_id') && $layout['d_login_box'] && $setts['is_ssl']!=1)
{
	$redirect =  (!empty($_REQUEST['redirect'])) ? $_REQUEST['redirect'] : $db->rem_special_chars($_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']);
	
	$template->set('redirect', $redirect);

	$menu_box_content	= $template->process('header_login_box.tpl.php');
	$template->set('menu_box_content', $menu_box_content);
}
else if (!$session->value('user_id') && $layout['d_login_box'] && $setts['is_ssl']==1)
{
	$menu_box_content = '<p align="center" class="contentfont">[ <a href="'.process_link('login').'"><strong>'.MSG_LOGIN_SECURELY.'</strong></a> ]</p>';
	$template->set('menu_box_content', $menu_box_content);
}
else if ($session->value('user_id'))
{
	$template->set('member_active', $session->value('membersarea'));
	$template->set('member_username', $session->value('username'));

	$is_announcements = $db->count_rows('content_pages', "WHERE MATCH (topic_lang) AGAINST
		('" . $session->value('site_lang') . "*' IN BOOLEAN MODE) AND page_handle='announcements'");

	if ($is_announcements)
	{
		(string) $announcements_content = null;

		$template->set('is_announcements', 1);

		$announcements_box_header = header6(MSG_ANNOUNCEMENTS . ' [<a title="show/hide" class="hidelayer" id="exp1102170555_link" href="javascript: void(0);" onclick="toggle(this, \'exp1102170555\');">–</a>]');
		$template->set('announcements_box_header', $announcements_box_header);

		$sql_select_announcements = $db->query("SELECT topic_id, topic_name, reg_date FROM " . DB_PREFIX . "content_pages WHERE
			MATCH (topic_lang) AGAINST	('" . $session->value('site_lang') . "*' IN BOOLEAN MODE) AND
			page_handle='announcements' ORDER BY topic_id DESC LIMIT 0,5");

		while ($announcement_details = $db->fetch_array($sql_select_announcements))
		{
			$announcement_content .= '<tr> '.
				'	<td class="c2"><img src="themes/' . $setts['default_theme'] . '/img/arrow.gif" width="8" height="8" hspace="4"></td> '.
				'	<td width="100%" class="c2 smallfont"><b>' . show_date($announcement_details['reg_date'], false) . '</b></td> '.
				'</tr> '.
				'<tr class="contentfont"> '.
				'	<td></td> '.
				'	<td><a href="' . process_link('content_pages', array('page' => 'announcements', 'topic_id' => $announcement_details['topic_id'])) . '"> '.
				'		' . $announcement_details['topic_name'] . '</a></td> '.
				'</tr>';

		}
		$template->set('announcement_content', $announcement_content);

		$announcements_box_content = $template->process('header_announcements_box.tpl.php');
		$template->set('announcements_box_content', $announcements_box_content);
		
	}

	$is_unread = $db->count_rows('messaging', "WHERE is_read=0 AND receiver_id='" . $session->value('user_id') . "' AND
		receiver_deleted=0");
	
	if ($is_unread)
	{
		$menu_box_content = '<div align="center" class="errormessage">' . MSG_YOU_HAVE_UNREAD_MESSAGES . '</div>';
	}
	
	$menu_box_content	.= $template->process('header_members_menu.tpl.php');
	$template->set('menu_box_content', $menu_box_content);
}

if ($setts['enable_header_counter'] && stristr($_SERVER['PHP_SELF'], 'index.php'))
{
	$template->set('header_site_status', header5(MSG_SITE_STATUS));

	$template->set('nb_site_users', $db->count_rows('users', "WHERE active='1'"));
 	$template->set('nb_live_auctions', $db->count_rows('auctions', "WHERE active='1' AND approved='1' AND closed='0' AND deleted='0' AND creation_in_progress='0'"));
	$template->set('nb_live_wanted_ads', $db->count_rows('wanted_ads', "WHERE active=1 AND closed=0 AND deleted=0"));
	
	if ($setts['enable_stores'])
	{
		$template->set('nb_live_stores', $db->count_rows('users', "WHERE active=1 AND shop_active=1"));		
	}

	$template->set('nb_online_users', online_users());
}

if ($layout['d_news_box'])
{
	$is_news = $db->count_rows('content_pages', "WHERE MATCH (topic_lang) AGAINST
		('" . $session->value('site_lang') . "*' IN BOOLEAN MODE) AND page_handle='news'");

	if ($is_news)
	{
		(string) $news_content = null;

		$template->set('is_news', $is_news);

		$news_box_header = header6(MSG_SITE_NEWS);
		$template->set('news_box_header', $news_box_header);

		$sql_select_news = $db->query("SELECT topic_id, topic_name, reg_date FROM " . DB_PREFIX . "content_pages WHERE
			MATCH (topic_lang) AGAINST	('" . $session->value('site_lang') . "*' IN BOOLEAN MODE) AND
			page_handle='news' ORDER BY topic_id DESC LIMIT 0," . $layout['d_news_nb']);

		$template->set('sql_select_news', $sql_select_news);

		$news_box_content = $template->process('header_news_box.tpl.php');
		$template->set('news_box_content', $news_box_content);
	}
}

if ($setts['enable_skin_change'])
{
	$template->set('site_skins_dropdown', list_skins('site', true, $session->value('site_theme')));
}

$template_output .= $template->process('header.tpl.php');
                                                                        
if (is_dir('install'))
{
	$template_output .= '<p align="center" class="errormessage">' . GMSG_INSTALL_DELETE_MESSAGE . '</p>';
}

$template->change_path('templates/');
?>
Edited by numnut3200
Link to comment
Share on other sites

So what code is setting the   $setts['default_theme']    variable?

 

This variable is either not defined at the time the code you posted is being executed, or it is in fact set to a empty value.

 

What is the output of

printf('<pre>%s</pre>', print_r($setts, true));

This will print the array structure to $setts. What does it show for the   default_theme   key?

Edited by Ch0cu3r
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.