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

condition
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 = """)
{
$this->db->select('*');
$this->db->from('user_details');
$this->db->where('');
}


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.

http://www.my-websiteabc.net/ works fine but not http://www.my-websiteabc.net/About_cookies

http://www.my-websiteabc.net/Home_controller and http://www.my-websiteabc.net/home_controller 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:

/.
   /my-websiteabc
   /my-websiteabc/application
   /my-websiteabc/js
   /my-websiteabc/css
   /my-websiteabc/system

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]
</IfModule>

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

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

5.My routes.php :

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

6.And config.php:

$config['base_url'] = 'http://www.my-websiteabc.net/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

I get File not found. when trying anything else than http://www.my-websiteabc.net/ 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(){

        $this->load->database();
    }

    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:
www.example.com/video?id=468/video-title

I want to rewrite it in htaccess so that it appears as:
www.example.com/video/video-title

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';
$domain="xxxxxxx.com";

class Google_model extends CI_Model
{
    public function __construct()
    {
        parent::__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)); 
        $Create_Error=1;
        try 
        { 
            $createUserResult = $dir -> users -> insert($UserInstance); 
            $Create_Error=0;
        } 
        catch (Google_IO_Exception $gioe) 
        { 
            $Create_Error=$gioe->getMessage(); 
        } 
        catch (Google_Service_Exception $gse) 
        { 
            $Create_Error=$gse->getMessage(); 
        } 
        return $Create_Error;
    }

    function Insert_User($First_Name,$Last_Name,$User_Name,$Password)
    {
        global $domain;
        $Error=0;

        $client = new Google_Client();
        $client->setAuthConfig('assets/auth/service_account.json');
        $client->useApplicationDefaultCredentials();
        $client->addScope('https://www.googleapis.com/auth/admin.directory.user');
        $email="admin@$domain";
        $client->setSubject($email);

        $dir = new Google_Service_Directory($client);
        $Error=self::Exist_user($dir,$User_Name);
        if(!$Error)
        {
            $Error=self::Create_User($dir,$First_Name,$Last_Name,$User_Name,$Password);
        }

        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

Backtrace:

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