Warning: Invalid argument supplied for foreach() in /home/globemel/public_html/libraries/joomla/database/database/mysqli.php on line 384
I have started getting this error which is preventing me from updating the database.... can anyone help
Warning: Invalid argument supplied for foreach() - help
Moderator: General Support Moderators
Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Security and Performance FAQs
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Security and Performance FAQs
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
-
- Joomla! Enthusiast
- Posts: 245
- Joined: Wed May 11, 2011 7:31 am
-
- Joomla! Apprentice
- Posts: 11
- Joined: Tue Jan 10, 2012 9:58 am
Re: Warning: Invalid argument supplied for foreach() - help
You have not declare database variable to null in table class!FDigital01 wrote:Warning: Invalid argument supplied for foreach() in /home/globemel/public_html/libraries/joomla/database/database/mysqli.php on line 384
I have started getting this error which is preventing me from updating the database.... can anyone help
just add your database field name and assign it a null value
for example:
var $name = null;
-
- Joomla! Apprentice
- Posts: 11
- Joined: Tue Jan 10, 2012 9:58 am
Re: Warning: Invalid argument supplied for foreach() - help
In view.html.php:
add
global $mainframe; on second line of display function.
in default case:
default:
// Prepare list array
$lists = array();
// Get the user state
$filter_order = $mainframe->getUserStateFromRequest(
$option.'filter_order',
'filter_order', 'published');
$filter_order_Dir = $mainframe->getUserStateFromRequest(
$option.'filter_order_Dir',
'filter_order_Dir', 'ASC');
// Build the list array for use in the layout
$lists['order'] = $filter_order;
$lists['order_Dir'] = $filter_order_Dir;
// Get revues and pagination from the model
// Assign references for the layout to use
$this->assignRef('lists', $lists);
In default.php
add following code instead of: <?php echo JText::_('ID'); ?>
<?php echo JHTML::_('grid.sort', JText::_('ID'), 'id',
$this->lists['order_Dir'],
$this->lists['order'] ); ?>
where JText::_('ID') is the name to display the field.
Id is database field.
At the end, add two hidden fields:
<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="" />
In models:
override function _buildQuery() as:
function _buildQuery()
{
$query = ' SELECT * '
. ' FROM #__hello'
. $this->_buildQueryOrderBy();
return $query;
}
function _buildQueryOrderBy()
{
global $mainframe, $option;
// Array of allowable order fields
$orders = array('id', 'name', 'email', 'gender', 'education', 'city', 'date', 'description', 'publish'); //containt name of fields inwhich u want to order you data
// Get the order field and direction, default order field
// is 'ordering', default direction is ascending
$filter_order = $mainframe->getUserStateFromRequest(
$option.'filter_order', 'filter_order', 'id');
// print_r($filter_order); exit;
$filter_order_Dir = strtoupper(
$mainframe->getUserStateFromRequest(
$option.'filter_order_Dir', 'filter_order_Dir', 'ASC'));
// Validate the order direction, must be ASC or DESC
if ($filter_order_Dir != 'ASC' && $filter_order_Dir != 'DESC')
{
$filter_order_Dir = 'ASC';
}
// If order column is unknown use the default
if (!in_array($filter_order, $orders))
{
// $filter_order = 'ordering';
}
$orderby = ' ORDER BY '.$filter_order.' '.$filter_order_Dir;
if ($filter_order != 'ordering')
{
//$orderby .= ' , ordering ';
}
// Return the ORDER BY clause
return $orderby;
}
add
global $mainframe; on second line of display function.
in default case:
default:
// Prepare list array
$lists = array();
// Get the user state
$filter_order = $mainframe->getUserStateFromRequest(
$option.'filter_order',
'filter_order', 'published');
$filter_order_Dir = $mainframe->getUserStateFromRequest(
$option.'filter_order_Dir',
'filter_order_Dir', 'ASC');
// Build the list array for use in the layout
$lists['order'] = $filter_order;
$lists['order_Dir'] = $filter_order_Dir;
// Get revues and pagination from the model
// Assign references for the layout to use
$this->assignRef('lists', $lists);
In default.php
add following code instead of: <?php echo JText::_('ID'); ?>
<?php echo JHTML::_('grid.sort', JText::_('ID'), 'id',
$this->lists['order_Dir'],
$this->lists['order'] ); ?>
where JText::_('ID') is the name to display the field.
Id is database field.
At the end, add two hidden fields:
<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="" />
In models:
override function _buildQuery() as:
function _buildQuery()
{
$query = ' SELECT * '
. ' FROM #__hello'
. $this->_buildQueryOrderBy();
return $query;
}
function _buildQueryOrderBy()
{
global $mainframe, $option;
// Array of allowable order fields
$orders = array('id', 'name', 'email', 'gender', 'education', 'city', 'date', 'description', 'publish'); //containt name of fields inwhich u want to order you data
// Get the order field and direction, default order field
// is 'ordering', default direction is ascending
$filter_order = $mainframe->getUserStateFromRequest(
$option.'filter_order', 'filter_order', 'id');
// print_r($filter_order); exit;
$filter_order_Dir = strtoupper(
$mainframe->getUserStateFromRequest(
$option.'filter_order_Dir', 'filter_order_Dir', 'ASC'));
// Validate the order direction, must be ASC or DESC
if ($filter_order_Dir != 'ASC' && $filter_order_Dir != 'DESC')
{
$filter_order_Dir = 'ASC';
}
// If order column is unknown use the default
if (!in_array($filter_order, $orders))
{
// $filter_order = 'ordering';
}
$orderby = ' ORDER BY '.$filter_order.' '.$filter_order_Dir;
if ($filter_order != 'ordering')
{
//$orderby .= ' , ordering ';
}
// Return the ORDER BY clause
return $orderby;
}
You do not have the required permissions to view the files attached to this post.
-
- Joomla! Fledgling
- Posts: 4
- Joined: Thu Nov 03, 2011 4:48 am
Re: Warning: Invalid argument supplied for foreach() - help
hi...adeelkalyami
i have a same problem with joomla. my site homepage shows:
-Warning: Invalid argument supplied for foreach() in frontpage.php on line 104
-Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in mysql.php on line 344.
i dont have any idea to solved it.
can anyone help me please...
this is urgently..
tq..
i have a same problem with joomla. my site homepage shows:
-Warning: Invalid argument supplied for foreach() in frontpage.php on line 104
-Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in mysql.php on line 344.
i dont have any idea to solved it.
can anyone help me please...
this is urgently..
tq..
Last edited by hafizsyrimo on Fri Jan 27, 2012 8:02 am, edited 2 times in total.
-
- Joomla! Apprentice
- Posts: 11
- Joined: Tue Jan 10, 2012 9:58 am
Re: Warning: Invalid argument supplied for foreach() - help
which version of php you are usinghafizsyrimo wrote:hi...adeelkalyami
i have a same problem with joomla. my site homepage shows:
-Warning: Invalid argument supplied for foreach() in /opt/lampp/htdocs/components/com_content/models/frontpage.php on line 104
-Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /opt/lampp/htdocs/libraries/joomla/database/database/mysql.php on line 344.
i dont have any idea to solved it.
can anyone help me please...
this is urgently..
tq..
-
- Joomla! Fledgling
- Posts: 4
- Joined: Thu Nov 03, 2011 4:48 am
Re: Warning: Invalid argument supplied for foreach() - help
i'm using php 5.2.9 on Apache/2.2.11
i'm using joomla 1.5.21
i'm using joomla 1.5.21