A PHP Error was encountered - El Forum - 11-17-2009
[eluser]jiahui[/eluser]
Hello, all experts.
What my problem is absolutely same with this article http://ellislab.com/forums/viewthread/45460/#580204 described
But, have tried with use the suggestions of that article what I found there, but my problem is still there.
This is the error message always appearing at the bottom of my web page.
Quote:A PHP Error was encountered
Severity: Warning
Message: Unknown: 2 result set(s) not freed. Use mysql_free_result to free result sets which were requested using mysql_query()
Filename: Unknown
Line Number: 0
Any kindness expert willing to guide me drive to the right path?
Following is my source code:
1. In Model :
Code: <?php
class usercontacts_model extends Model {
function get_admin_contacts()
{
$this->db->where('banned = 0');
$this->db->orderby('lastname', 'asc');
return $this->db->get('user');
}
}
?>
2. In Controller :
Code: function index()
{
$data['accounts'] = $this->usercontacts_model->get_admin_contacts();
}
3. views :
Code: <?php foreach($accounts->result() as $user):?>
<tr>
<td><?php echo $user->firstname.' '.$user->lastname; ?></td>
<td><?php echo $user->email; ?></td>
<td><?php echo $user->phone; ?></td>
<td><?php if ($user->groupid==1) { ?>
<img src="<?php echo base_url();?>images/admin.png" border="0" alt="Admin"/>
<?php } else if ($user->groupid==2) { ?>
<img src="<?php echo base_url();?>images/exporter.png" border="0" alt="Exporter"/>
<?php } else if ($user->groupid==3) { ?>
<img src="<?php echo base_url();?>images/importer.png" border="0" alt="Importer"/>
<?php } ?>
<?php if ($user->groupid==1) { ?>
Administrator
<?php } else if ($user->groupid==2) { ?>
Exporter
<?php } else if ($user->groupid==3) { ?>
Importer
<?php } ?></td>
<td><?php echo $user->ip_address; ?></td>
<td><?php echo $user->last_login; ?></td>
<td align="center">
<?php if ($this->session->userdata('groupid')==1){ ?>
<?php echo ' ['.anchor('accounts/delete/'.$user->id, $this->lang->line('actions_delete'),array('class' => 'delete', 'title'=>$user->firstname)).']';?>
<a >id; ?>"><img src="<?php echo base_url(); ?>images/edit.png" border="0"/></a>
<?php }else if ($this->session->userdata('user_id')== $user->id) { ?>
<a >id; ?>"><img src="<?php echo base_url(); ?>images/edit.png" border="0"/></a>
<?php } ?>
</td>
</tr>
<?php endforeach;?>
A PHP Error was encountered - El Forum - 11-18-2009
[eluser]jiahui[/eluser]
Was my question not clear? None feedback?
A PHP Error was encountered - El Forum - 11-18-2009
[eluser]John_Betong[/eluser]
[quote author="jiahui" date="1258619670"]Was my question not clear? None feedback?[/quote]
http://ellislab.com/forums/viewthread/130302/#653952
Try:
1. download the above function and save it to a file
2. require the function in your index.php
Temporarily change these lines of code
Code: // return $this->db->get('user');
$query = $this->db->get('user');
fred($query->result());
die;
Once you know the results, move on to your next lines of code.
edit: spelling
A PHP Error was encountered - El Forum - 11-19-2009
[eluser]jiahui[/eluser]
I saved the file in views folder. And require the file in my index.php , also changed my query to : Code: $query = $this->db->get('user');
fred($query->result());
die;
But what I get is Quote:Fatal error: Call to undefined function fred() in C:\inetpub\sgcarmart\hoorfatt\system\application\models\usercontacts_model.php on line 11
Any comments?
Thank you
A PHP Error was encountered - El Forum - 11-19-2009
[eluser]John_Betong[/eluser]
[quote author="jiahui" date="1258633508"]I saved the file in views folder. And require the file in my index.php , also changed my query to : Code: $query = $this->db->get('user');
fred($query->result());
die;
But what I get is Quote:Fatal error: Call to undefined function fred() in C:\inetpub\sgcarmart\hoorfatt\system\application\models\usercontacts_model.php on line 11
Any comments?
Thank you[/quote]
Save the function in a file called _fred.php in the same directory as your index.php.
In your index,php include the file by using require('_fred.php');
If there is any problem with the _fred.php file then your index.php will show an error and stop processing. Including the file shows any errors but continues processing.
Once _fred.php is being called correctly the fiunction fred($whatever_variable_you_choose); is then available everywhere in your program.
Try it again and let us know the results.
A PHP Error was encountered - El Forum - 11-19-2009
[eluser]jiahui[/eluser]
This is the result list I got:
Code: Name ==> [b]missing_$data_name[/b]
Type ==> array(10)
Count ==> 10
Value ==>
Array
(
[0] => stdClass Object
(
[id] => 12
[username] => ddd.ddddddd
[password] => UGNSPwEzBzdSZQ1pBWVTPQ==
[ip_address] => ::1
[groupid] => 3
[firstname] => ddd
[lastname] => dddddd
[email] => [email protected]
[phone] =>
[last_login] => 0000-00-00 00:00:00
[banned] => 0
)
[1] => stdClass Object
(
[id] => 8
[username] => ee.eeee
[password] => eeeeeeee
[ip_address] => ::1
[groupid] => 1
[firstname] => ee
[lastname] => ee
[email] => [email protected]
[phone] =>
[last_login] => 0000-00-00 00:00:00
[banned] => 0
)
[2] => stdClass Object
(
[id] => 15
[username] => jiahui.jiahui
[password] => BzoDYww7CjZUcgdu
[ip_address] => ::1
[groupid] => 3
[firstname] => jiahui
[lastname] => jiahui
[email] => [email protected]
[phone] =>
[last_login] => 0000-00-00 00:00:00
[banned] => 0
)
[3] => stdClass Object
(
[id] => 16
[username] => law.keng boon
[password] => CmwBOlE0BGRTNQQy
[ip_address] => ::1
[groupid] => 2
[firstname] => law
[lastname] => keng boon
[email] => [email protected]
[phone] =>
[last_login] => 2009-11-17 11:09:47
[banned] => 0
)
[4] => stdClass Object
(
[id] => 10
[username] => dd.qqq
[password] => 12121212
[ip_address] => ::1
[groupid] => 2
[firstname] => dd
[lastname] => qq
[email] => [email protected]
[phone] =>
[last_login] => 0000-00-00 00:00:00
[banned] => 0
)
[5] => stdClass Object
(
[id] => 1
[username] => jiahui
[password] => C20JMlYzBWUBZwcxXm0KOA==
[ip_address] => ::1
[groupid] => 1
[firstname] => huggie puppy
[lastname] => Standford
[email] => [email protected]
[phone] =>
[last_login] => 2009-11-20 10:16:58
[banned] => 0
)
[6] => stdClass Object
(
[id] => 11
[username] => 666666
[password] => 66666
[ip_address] => ::1
[groupid] => 2
[firstname] => testing
[lastname] => tr
[email] => [email protected]
[phone] =>
[last_login] => 0000-00-00 00:00:00
[banned] => 0
)
[7] => stdClass Object
(
[id] => 9
[username] => rtr.trttr
[password] => rrrrrrr
[ip_address] => ::1
[groupid] => 2
[firstname] => rtr
[lastname] => trt
[email] => [email protected]
[phone] =>
[last_login] => 0000-00-00 00:00:00
[banned] => 0
)
[8] => stdClass Object
(
[id] => 13
[username] => ddd
[password] => BWYINQNhBWUBZlBkBDQFOwQw
[ip_address] => ::1
[groupid] => 3
[firstname] => erttrty
[lastname] => tt
[email] => [email protected]
[phone] =>
[last_login] => 0000-00-00 00:00:00
[banned] => 0
)
[9] => stdClass Object
(
[id] => 7
[username] => xx.xxxx
[password] => xxxxxxxx
[ip_address] => ::1
[groupid] => 3
[firstname] => xx
[lastname] => xx
[email] => [email protected]
[phone] =>
[last_login] => 0000-00-00 00:00:00
[banned] => 0
)
)
Could tell me what is the indeed problem caused this error msg appearing all the times?
Code: A PHP Error was encountered
Severity: Warning
Message: Unknown: 2 result set(s) not freed. Use mysql_free_result to free result sets which were requested using mysql_query()
Filename: Unknown
Line Number: 0
A PHP Error was encountered - El Forum - 11-19-2009
[eluser]John_Betong[/eluser]
[quote author="jiahui" date="1258705983"]This is the result list I got:
Code: Name ==> [b]missing_$data_name[/b]
Type ==> array(10)
Count ==> 10
Value ==>
Array
(
[0] => stdClass Object
(
[id] => 12
[username] => ddd.ddddddd
[password] => UGNSPwEzBzdSZQ1pBWVTPQ==
[ip_address] => ::1
[groupid] => 3
[firstname] => ddd
[lastname] => dddddd
[email] => [email protected]
[phone] =>
[last_login] => 0000-00-00 00:00:00
[banned] => 0
)
[1] => stdClass Object
(
[id] => 8
[username] => ee.eeee
[password] => eeeeeeee
[ip_address] => ::1
[groupid] => 1
[firstname] => ee
[lastname] => ee
[email] => [email protected]
[phone] =>
[last_login] => 0000-00-00 00:00:00
[banned] => 0
)
...
...
)
Could tell me what is the indeed problem caused this error msg appearing all the times?
Code: A PHP Error was encountered
Severity: Warning
Message: Unknown: 2 result set(s) not freed. Use mysql_free_result to free result sets which were requested using mysql_query()
Filename: Unknown
Line Number: 0
[/quote]
Please note that the error message returned is not an error it is a warning. You could hide the warning by changing the error level setting.
I would be tempted to exactly pinpoint where the message is appearing and then take steps to free the result set by using $result->free_result();.
Normally the result set is freed automatically but it appears to be some sort of conflict. To eliminate this I would free the result set every time immediately after I have stored the result set.
A PHP Error was encountered - El Forum - 11-19-2009
[eluser]jiahui[/eluser]
How to do that?
Because I intend to set it like this Code: <?php foreach($accounts->free_result() as $user):?>
or Code: <?php foreachmy sql_free_result(accounts->result() as $user)):?>
but cannot work.
Could teach me whether got another efficient way to block this msg in front of user?
A PHP Error was encountered - El Forum - 11-19-2009
[eluser]John_Betong[/eluser]
[quote author="jiahui" date="1258710546"]How to do that?
Because I intend to set it like this Code: <?php foreach($accounts->free_result() as $user):?>
or Code: <?php foreachmy sql_free_result(accounts->result() as $user)):?>
but cannot work.
Could teach me whether got another efficient way to block this msg in front of user?[/quote]
Try this:
Code: function get_admin_contacts()
{
$this->db->where('banned = 0');
$this->db->orderby('lastname', 'asc');
$result = $this->db->get('user');
$this->db->free_result();
return $result;
}
}
A PHP Error was encountered - El Forum - 11-19-2009
[eluser]jiahui[/eluser]
Thank you for your patient.
I tried but got this error msg :
Quote:Fatal error: Call to undefined method CI_DB_mysql_driver::free_result() in C:\inetpub\sgcarmart\hoorfatt\system\application\models\usercontacts_model.php on line 10
|