How can I retrieve data from the database by querying records between two dates using codeigniter?
Here is my code :
function date_employee_details($id,$fdate,$sdate)
{
$this->db->select('*');
$this->db->where('user_id',$id);
$this->db->where('dates >=',$fdate);
$this->db->where('dates <=',$sdate);
return $this->db->get('attendance');
}
but i got an error :
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: fdate
Filename: models/admin.php
Line Number: 726
thanks
Related
There's something weird going on with server-side Datatables from this: https://github.com/n1crack/Datatables.
Don't understand what's going on, i do exactly the same thing as the examples but it simply doesn't work. According to the "where" example https://github.com/n1crack/Datatables/blob/master/public/examples/where/ajax.php, look how simple it should be:
$dt = new Datatables(new MySQL($config));
$dt->query("Select film_id as fid, title, description from film where film_id > 47 and film_id < 83");
echo $dt->generate();
My code:
$config = [ 'host' => 'localhost',
'port' => '3306',
'username' => 'root',
'password' => '',
'database' => 'sys_db_gincana' ];
$dt = new Datatables( new MySQL($config) );
$dt->query("
SELECT seen, id, name, cep, date_format(created,'%d/%m/%Y %h:%i:%s') as created
FROM user
");
echo $dt->generate();
Now look at what my js console prints from my ajax:
A PHP Error was encountered
Severity: 4096 Message: Argument 1 passed to
PHPSQLParser\builders\WhereBuilder::build() must be of the type array,
boolean given, called in C:\Program Files
(x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\gincana\vendor\greenlion\php-sql-parser\src\PHPSQLParser\builders\SelectStatementBuilder.php
on line 74 and defined Filename: builders/WhereBuilder.php
Line Number: 112
A PHP Error was encountered
Severity: Warning Message: Invalid argument supplied for
foreach() Filename: builders/WhereBuilder.php Line
Number: 114
A PHP Error was encountered
Severity: 4096 Message: Argument 1 passed to
PHPSQLParser\builders\WhereBuilder::build() must be of the type array,
boolean given, called in C:\Program Files
(x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\gincana\vendor\greenlion\php-sql-parser\src\PHPSQLParser\builders\SelectStatementBuilder.php
on line 74 and defined Filename: builders/WhereBuilder.php
Line Number: 112
A PHP Error was encountered
Severity: Warning Message: Invalid argument supplied for
foreach() Filename: builders/WhereBuilder.php Line
Number: 114
Fatal error: Call to a member function
fetch_assoc() on a non-object in C:\Program Files
(x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\gincana\vendor\ozdemir\datatables\src\DB\MySQL.php
on line 40
And if if i change the query to:
$dt = new Datatables( new MySQL($config) );
$dt->query("
SELECT seen, id, name, cep, date_format(created,'%d/%m/%Y %h:%i:%s') as created
FROM user
WHERE approved = 0 and canceled = 0
");
echo $dt->generate();
the error changes:
A PHP Error was encountered
Severity: Warning Message: array_merge(): Argument #2 is
not an array Filename: src/Datatables.php Line Number:
47
Fatal error: Call to a member function
fetch_assoc() on a non-object in C:\Program Files
(x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\gincana\vendor\ozdemir\datatables\src\DB\MySQL.php
on line 40
Well, the library is a bit new (january 2015), i wonder if someone that had success using it could help me.
Regards
The problem in the WhereBuilder comes from the PHPSQLParser, can you test the latest version from https://github.com/greenlion/PHP-SQL-Parser? It seems to be a simple SQL statement, so actually it should work. I have moved your issue to GitHub, please follow the changes there.
A PHP Error was encountered
Severity: Notice
Message: Undefined index: elements_id
Filename: views/showdetail.php
Line Number: 17
Help me please!
Error on server openshift but Run on localhost no error.
How to fix?
Do this with each variable
$elements_id=isset($row['elements_id'])?$row['elements_id']):'';
You are trying to use the vale of the index of the array without checking first if is set
<?php
print_r($dataelements);
foreach ($dataelements as $row) {
$elements_id =$row['elements_id'];
$elements_number = $row['elements_number'];
$elements_name = $row['elements_name'];
$elements_principle = $row['elements_principle'];
$elements_standard = $row['elements_standard'];
$elements_indicator = $row['elements_indicator'];
}
?>
I'm getting this error and after checking for similar errors I verified the syntax is correct. The complete error is;
WRITE OK
READ OK
Notice: Undefined variable: dbRead in C:\vhosts\phpcs5\lesson07\workfiles\scripts\user_registration.php on line 28
Fatal error: Call to a member function quoteInto() on a non-object in C:\vhosts\phpcs5\lesson07\workfiles\scripts\user_registration.php on line 28
My connection is defined as:
$dbwrite = new Zend_Db_Adapter_Pdo_Mysql($write);
$dbread = new Zend_Db_Adapter_Pdo_Mysql($read);
I did a test first to make sure it can see the database which is what the Write OK and Read OK are as follows;
if ($dbwrite->getConnection()) {
echo 'WRITE OK<br/>';
}
if ($dbread->getConnection()) {
echo 'READ OK';
}
So I'm not sure why I'm getting this error.
dbRead is undefined. You've defined $dbread. Note the capitalization.
Look through your code base (particularly user_registration.php line 28) and switch all instances to one or the other.
trying to make some dynamic combobox and found some troubles..
here's the code
controller
$this->load->model('main_model');
$data['sales'] = $this->main_model->getSales();
$this->load->view('dashboard_view',$data);
the model
$this->db->select('*');
$this->db->from('salesman');
$this->db->where('cabangid',$cabangid);
$this->db->order_by('salesmanid','ASC');
$array_keys_values = $this->db->get();
foreach ($array_keys_values->result() as $row)
{
$result[0]= '- sales-';
$result[$row->salesmanid]= $row->description;
}
return $result;
the view
<div id="sales" style="width:250px;float:left;">
sales: <br/>
<?php
echo form_dropdown("salesmanid",$sales,"","id='salesmanid'");
?>
the error are like these..
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: sales
Filename: views/dashboard_view.php
Line Number: 14
and
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: helpers/form_helper.php
Line Number: 331
any help would be appreciated..:D
I'm using FX.php together with Codeigniter to access a Filemaker DB. Library and config file are autoloaded in config/autoload.php.
This setup works perfectly well on my development machine (OS X, PHP 5.3.14). However, when I run the project on our dev server (Ubuntu Precise, PHP 5.3.10), it doesn't work. There seems to be an issue with the config parameters not being passed to the library. I get the following error messages:
Severity: Notice
Message: Undefined index: dataServer
Filename: libraries/CIFX.php
Line Number: 9
Severity: Notice
Message: Undefined index: dataPort
Filename: libraries/CIFX.php
Line Number: 9
Severity: Notice
Message: Undefined index: dataType
Filename: libraries/CIFX.php
Line Number: 9
Severity: Notice
Message: Undefined index: dataURLType
Filename: libraries/CIFX.php
Line Number: 9
My libraries/CIFX.php file looks like this:
require('FX.php');
class CIFX extends FX {
function __construct ($params = array())
{
parent::__construct($params['dataServer'], $params['dataPort'], $params['dataType'], $params['dataURLType']);
}
}
?>
My config/CIFX.php file looks like this:
$config['dataServer'] = '192.168.1.10';
$config['dataPort'] = '80';
$config['dataType'] = 'FMPro7';
$config['dataURLType'] = '';
$config['dbuser'] = '';
$config['dbpassword'] = '';
According to the Codeigniter manual, this should be working.
Any help much appreciated!
you need to be Passing Parameters When Initializing Your Class
$params = array(
'dataServer' => $this->config->item('dataServer');,
'dataPort' => $this->config->item('dataPort');
);
$this->load->library('CIFX ', $params);