how to get data from database using date between?

Database stored date

item 1: date from :- 10-07-2017 date to :- 20-07-2017
item 2: date from :- 02-07-2017 date to :- 02-08-2017
item 3: date from :- 01-06-2017 date to :- 20-08-2017

input date

start date:- 05-07-2017 end date :- 25-07-2017

here I gave an input date to get data from database. database stored date is the data I want to print. thing is that, which are the items date included in the input date

this are the condition I want to work

start_date < date from && end_date > date_to 
start_date > date from && end_date > date_to 
start_date < date from && end_date < date_to 
start_date > date from && end_date < date_to 

exception case

start_date < end_date < date_to
start_date > end_date > date_to

I want a codeignitor solution . below am giving my model class structure

public function getDate( $start_date = "",$end_date = """)

Source: stackoverflow-php

Integrating PHP Like and Unlike into codeigniter

I’m trying to create a Like and Dislike button in codeigniter when clicked it adds one to the like and dislike value. The button will be saved in database as int on the mySql questions table (the questions table contains id,body,date,like,fields) and every time the button has gets clicked it the like or dislike field is updated in the database by adding 1 to it. I have tried thinking about this but am getting confused. If anybody has a simple code with the Model, View, and Controller, I’d be very grateful

Source: stackoverflow-php

File not Found Codeigniter in production

So I’ve put my website online and only my landing page (Home_controller) is working fine but any other page is not working. works fine but not and don’t work either.

I’ve spent all day reading different suggestions and workarounds but can’t get it to work.

What I’ve tried so far:

1.My Controllers filenames and Classes have a first Uppercase character. For instance:

  • About_cookies.php
  • class About_cookies extends CI_Controller
  • View: cookies.php

2.My folder structure is:


3.I have .htaccess in the root folder contains:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

4.I also tried with/without this .htaccess in the application folder:

<IfModule authz_core_module>
Require all denied
<IfModule !authz_core_module>
Deny from all

5.My routes.php :

$route['default_controller'] = 'Home_controller';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

6.And config.php:

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

I get File not found. when trying anything else than but on this page all the images and CSS are correct so I guess my path is correct.

Using CI 3.1.5 and PHP 7.1.6

Source: stackoverflow-php

Codeigniter: Undefined index error [duplicate]

I’m getting an error when trying to display database results in my view saying that the index is undefined.

The error message is- Message: Undefined index: StudentNumber

Here is my model:

class CurrentUser_model extends CI_Model {

    public function __construct(){


    public function get_userinfo($studentNumber){

        $query = $this->db->select('ProgramName, StudentNumber, UserName, FirstName, LastName, Email, Program, Year, Notes')
                          ->from('Users, Programs')
                          ->where('StudentNumber', $studentNumber)
                          ->where('ProgramID', 'Program');

        return $query->get()->result_array();

My controller:

public function index(){

        $data['title'] = 'Current User';

        $studentNumber = 040828055;

        $data['userinfo']    = $this->CurrentUser_model->get_userinfo($studentNumber);

        $this->load->view('CurrentUser/index', $data);

and in my view I’m trying to do this:

echo $userinfo['StudentNumber'];

Source: stackoverflow-php

Codeigniter database reset cache query after one detetion

I have a function which allow me to delete a row on a table. But the problem is that, for database integrity, I have to delete another row on another table that is in relation with the record I want to delete. This is my function :

public function delete($tab)
        $this->db->where('id', $tab['id']);
        $this->db->delete('agent', $tab);
        $this->db->where('id_agent', $tab['id']);
        $this->db->delete('agent_vendeuse', $tab);

I have an error database error on my function :

DELETE FROM `agent_vendeuse` WHERE `id_agent` = '2' AND `id` = '2'

Which means that after I affected the new index ‘id_agent’ for the where clause, the previous one ‘id’ is still in cache.

I guess I have to clean the case after the first deletion but how to write it ?

Source: stackoverflow-php

Rewrite URL to hide id

I have the following url on my website:

I want to rewrite it in htaccess so that it appears as:

What regex do i need to use in this scenario for the proper rewrite?

Source: stackoverflow-php

Codeigniter and google api integration fail

I am trying to call google api from codeigniter. I have unzipped the google api php library in a directory named asset of the codeigniter root directory. I use the following code to create a user.

require_once 'assets/vendor/autoload.php';

class Google_model extends CI_Model
    public function __construct()

    function Create_User($dir,$Given_Name,$Family_Name,$User_Name,$Password)//create a user 
        global $domain;
        $UserInstance = new Google_Service_Directory_User(); 
        $NameInstance = new Google_Service_Directory_UserName(); 

        $NameInstance -> setGivenName($Given_Name); 
        $NameInstance -> setFamilyName($Family_Name); 

        $UserInstance -> setName($NameInstance); 
        $UserInstance -> setHashFunction("MD5"); 
        $UserInstance -> setPrimaryEmail("$User_Name@$domain"); 
        $UserInstance -> setPassword(hash("md5", $Password)); 
            $createUserResult = $dir -> users -> insert($UserInstance); 
        catch (Google_IO_Exception $gioe) 
        catch (Google_Service_Exception $gse) 
        return $Create_Error;

    function Insert_User($First_Name,$Last_Name,$User_Name,$Password)
        global $domain;

        $client = new Google_Client();

        $dir = new Google_Service_Directory($client);

        return $Error;

When I use Insert_User routine to create a user, it fails after calling the function Create_User on the line

$createUserResult = $dir -> users -> insert($UserInstance);

with an error Severity: Error

Message: Call to undefined method Google_Service_Directory_User::toSimpleObject()

Filename: Service/Resource.php

Line Number: 108


How can I fix this?

Source: stackoverflow-php

css is not loading in codeigniter 3.1

I am using codeigniter 3.1.
I am trying to read base_url from config file .
However hardcode value is working fine for the same .
my code to read base_url is :

<link rel="stylesheet" type="text/css" href='<?php echo base_url('assets/css/bootstrap.min.css'); ?>' />
<script src='<?php echo base_url('assets/js/bootstrap.min.js'); ?>' />
<link rel="stylesheet" type="text/css" href='<?php echo base_url('assests/css/styles.css'); ?>' />

My config is as follow :

$config['base_url'] = "http://localhost:63342/CI/";

Source: stackoverflow-php