CodeIgniter

36

Solutions

52

Contributors

Share tech news, updates, or what's on your mind.

Sign up to Post

I keep getting this error every time I go to the chargeticket_list page.

Controller

public function chargeticket_list() {
$data['charge_tickets'] = $this->Chargeticket_model->list_charges($this->input->post('date1'), $this->input->post('date2'));
$this->load->view( 'inc/header' );
$this->load->view( 'chargeticket/chargeticket_list', $data );
$this->load->view( 'inc/footer' );
}

Open in new window

Model

public function list_charges($date1, $date2) //This function returns an array
    {   $this->db->join( 'customers', 'charges.idcustomers = customers.idcustomers' );
        $this->db->where('ch_date >=', $date1);
        $this->db->where('ch_date <=', $date2);
        $query = $this->db->get('charges'); //create query
        return $query->result_array(); //creates array from query
    }

Open in new window

View

<script type="text/javascript">

$(document).ready(function (){
    $('.date1').datepicker({
dateFormat: 'yy-mm-dd'});
});

$(document).ready(function (){
    $('.date2').datepicker({
dateFormat: 'yy-mm-dd'});
});
</script>

<div class="container">
<?php 
    $attributes = array('id'=>'chargeticket_list', 'class'=> 'form-horizontal');
    echo form_open('chargeticket/chargeticket_list', $attributes);
?>

<div class="form-group">
    <?php $ldata = array('class' => 'control-label col-sm-4');
    echo form_label('From','date1', $ldata ); 
    $data = array('class' => 'form-control date1','name' => 'date1');?>
    <div class="col-sm-4"><?php 

Open in new window

0
Firewall Management 201 with Professor Wool
Firewall Management 201 with Professor Wool

In this whiteboard video, Professor Wool highlights the challenges, benefits and trade-offs of utilizing zero-touch automation for security policy change management. Watch and Learn!

Hi Experts

Have an odd request to get done.  I have two applications, one in normal php (property application) and other in framework codeigniter (support application).  I need a way to be able to login from property app into support application automatically once logged into Property application.  Hope that makes...

When i click a link "support", goes to external application, and will prompt to login.  The same login credentials exist on both applications..and what needs to happen is some kind of login process based on the session from property app...that way a user would not have to login again..

Is this possible?
0
OK I think this is the weirdest yet.  To me, anyway.

If I leave in lines 3,4,5 the code appears to work (displays the array, shows no error).

If I comment out those lines, it fails
Severity: Notice

Message: Undefined offset: 0

Filename: models/Week_fixtures_model.php

Line Number: 490

if ( $query->num_rows() == 1)
		{
			echo "<PRE>";
			print_r($query->result_array());
			echo "</PRE>";
			$arr_venue_info['name'] = $query->result_array[0]['name'];
			$arr_venue_info['mapref'] = $query->result_array[0]['mapref'];
			return $arr_venue_info;	
		}
		else // no ground found.
		{
			$arr_venue_info['name'] = $venue;
			$arr_venue_info['mapref'] = 'No map';
			return $arr_venue_info;	
		}

Open in new window


Can anyone shed any light on this please?  I'm using CodeIgniter if that is relevant.
0
Parse error: syntax error, unexpected T_CONST in C:\wamp\www\codeigniter\system\core\CodeIgniter.php on line 58
0
Hi experts,
I need to reproduce this query in CodeIgniter, using ActiveRecord.  I've got very close but CI is putting backquotes where they are not wanted (the yellow-highlighted ones).
Here's the query and CI's interpretation of it...
query as interpreted by CIand here's the code I used to get it.  Part of this stems from CI's lack of support for UNION.
public function get_squad ($fixture_id, $side)
	{	
		$team_clause = 'X';
		if($side=='1') {$team_clause = ' p_1sts ';}
		if($side=='2') {$team_clause = ' p_2nds ';}
		if($side=='3') {$team_clause = ' p_3rds ';}
		if($side=='4') {$team_clause = ' p_4ths ';}
		if($side=='S') {$team_clause = ' p_sundays ';}
		if($side=='T') {$team_clause = ' p_sundays_res ';}
		if($side=='V') {$team_clause = ' p_young_vets ';}
		if($side=='W') {$team_clause = ' p_senior_vets ';}
		
		$this->db->select('first_name, surname, id AS "player_id", "Y" AS "player_picked", fp_keeper AS "keeper", fp_owes_subs AS "subs", fp_if_fit AS "fit", fp_if_available AS "available"');
		$this->db->from('fixtures_players');
		$this->db->join('players_members', 'fp_player_id = id', 'INNER');
		$this->db->where('fp_fixture_id', $fixture_id);
		$this->db->group_by(array('first_name', 'surname'));
		$first_half_inner_union = $this->db->get_compiled_select(); 		
		
		$this->db->select('first_name, surname, id AS "player_id", "N" AS "player_picked", "" AS "keeper", "" AS "subs", "" AS "fit", "" AS "available"');
		$this->db->from('players_members');
		

Open in new window

0
Weird!  Hopefully this is an easy 1000 points for someone.

This is taken straight from the manual, and I get an error - anyone see it?  I'm using CodeIgniter if that's relevant at all.

syntax error, unexpected '$v' (T_VARIABLE) in C:\xampp\htdocs1\fobg\application\controllers\week_fixtures.php on line 31

public function date_chosen()
      {            
            $a = array(1, 2, 3, 17);

            foreach ($a as $v) {
                echo "Current value of \$a: $v.\n";
            }
      }

also flagged up in Dreamweaver:
DW screenshot
0
Hello experts,

I am trying to check if the post data obtained for 'fields' is empty. I have tried different conditions to check if the array is empty or not. Even if the 'fields' is empty, the if condition executes. It would be great if someone could suggest me as to how to go about with this.

View:
<h4>Alternatives</h4><input type="text" style="width:700px;display: inline" id="fields" name="fields[]" placeholder="Enter Method Name" class="form-control method_list_list"/> <input type="button" name="addmore" id="addmore" class="btn btn-success" value="Add More"/>

Model:
public function addmethodtotask(){
	 $conn= mysqli_connect("localhost","root","","cognitivewalkthrough");
	 $taskid=  $_POST['taskid'];
	$description =  $_POST['reason'];
	$action = $_POST['action'];

//if (isset($_POST['fields']) && $_POST['fields'] != "") {
	if (isset($_POST['fields']) && $_POST['fields'] != NULL) {
	// if (count($_POST['fields'])>0 && !empty($_POST['fields'])) {
		 echo "whey am i here";
				foreach ( $_POST['fields'] as $key=>$value ) {
					$sql_website = sprintf("INSERT INTO method (methodname,description,action) VALUES ('%s','%s','%s')",mysqli_real_escape_string($conn,$value),mysqli_real_escape_string($conn,$description),mysqli_real_escape_string($conn,$action) );
					$this->db->query($sql_website);
					$inserted_method_id = $this->db->insert_id();
				}
	}
        

Open in new window

0
I added codeigniter 'table' to my project and i got desired outcome for view except for the fact that the way i had it before i was able to delete record by clicking on them since they were anchor tags, i would like to know how to recreate this in new table format. Thanks!
site_model.php
site.php
options_view.php
Capture2.PNG
Capture.PNG
0
how to logout in php using codeignter
0
how to create login page in php using codeigniter
0
Making Bulk Changes to Active Directory
LVL 8
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Hi Experts

Could you point a way to make a Codeigniter view have a very long timeout?

This view maintains a dashboard open in a TV during a long time. This dashboard presents information from time to time by using code like:

 $.getJSON("survey_dashboard/get_totais", function (data) {
	$.each(data, function (g, grupo) {
		if (grupo.GRUPO == 'TOTAL') {
			total = grupo;
		} else if (grupo.GRUPO == 'ATIVO') {
			ativo = grupo;
		} else if (grupo.GRUPO == 'RECEPTIVO') {
			receptivo = grupo;
		} else if (grupo.GRUPO == 'VIVO') {
			vivo = grupo;
		}
	});

Open in new window


Where
survey_dashboard/get_totais

Open in new window


is a Controller function  that calls a SP

...
  public function get_totais() {

        $data = array();
        $data = $this->survey_model->new_get(array('query' => "CALL proc_pesquisa_totais()"));
        die(json_encode($data));
    }

Open in new window


Because an user first need to login the system to charge the dashboard-  this start countnig time,  after the timeout is reached the dashboard closes.

Does CI has a way to extend this time?

Thanks in advance
0
Hi Experts

Could you point whyat's needed to a Codeigniter app to correctly be started?

When opened the app presents this screen

img006
And index.php must be fired to make it start.


Another app under the same htdocs present  the login screen but only correctly runs if index.php is used in the path.

Thanks in advance!
0
Hi Experts

Could you point what is preventing a Codeigniter app that is perfectly running localy to run in a remote server?

I'm facing this amazing occurrence:
When the complete app is locally copied and pasted under remote server htdocs folder, the adjustments are done in config.php and database.php

img001
config.php
// IP Configured
$config['base_url'] = 'http://10.xxx.x.223/meetasas_system/'

Open in new window


database.php is correctly pointing DB after some changes.

When the app is called the controller auth is not found... but it exists as the picture below shows.

Is it a matter of any other configuration?

Could you point a workaround?

Thanks in advance!
0
I have to solve this issue which I'm not able to solve :( I have a blog in PHP and an ecommerce site built with CodeIgniter. Both sites have the same session informations shared, but if I go on the blog and I login, when I pass on the ecommerce the user is not recognized and the ecommerce ask for a new login to the user.

In the blog part I set the session in this way:

<?php

include("config.php");

if(isset($_GET['logout'])){
    $servername = 'localhost';
    $username = 'wtgecomm_ecomm';
    $password = 'ElFDeOD$o_qd';
    $dbname ='wtgecomm_ecommerce';
    $conn = new mysqli($servername, $username, $password, $dbname);
     $sql = "DELETE FROM `ci_sessions` WHERE id="."'".$_COOKIE['ci_session']."'";
    if (!$conn->query($sql)) {
   // printf("Message d'erreur : %s\n", $conn->error);
}
    //$result = $conn->query($sql);
    //var_dump($result);
$_SESSION['login_id'] = '';
$_SESSION['customer_id'] = '';
unset($_SESSION['customer_id']);
unset($_SESSION['client']);
unset($_COOKIE['ci_session']);
session_destroy();
//var_dump($_SESSION);
header( 'Location: /'); 
}
if(isset($_REQUEST['login_id']) && !empty($_REQUEST['login_id']) ){

    $ci_session = $_COOKIE['ci_sessions'];
    $login_id = $_REQUEST['login_id'];
//  $sql = "INSERT INTO `ci_sessions` (`id`,`data`) VALUES ('2121212','121212121212')";
//  $ctx->exec($sql) ;
    $servername = 'localhost';
    $username = 'wtgecomm_ecomm';
    $password = 'ElFDeOD$o_qd';
    $dbname ='wtgecomm_ecommerce';
    $conn = 

Open in new window

0
How do I return the results of a query as JSON echo to screen?
0
Hi Experts


Could you point what's preventing a query that perfectly runs under MySQL IDE produces no result when running in PHP?

And what is needed to workaround it?


The query uses a special character in the where clause:

$analista = $where['like']['created_by'];
	
//     print_r($analista);
//            die;
	
	$query['query'] = "
			SELECT  
				sg.nome_seguradora as cliente_corporativo,
				DATE_FORMAT(data, '%d/%m/%y') as mes,
				it._name as analista,
				IF(interna_externa = 'I', 'Interna',IF(interna_externa ='E', 'Externa','-')) as interna_externa,
				enviado_por,
				nome_reclamante,
				IF(genero = 'M','Masculino',IF(genero = 'F','Feminio','-')) as genero,
				IF(fisica_juridica = 'F','Física',IF(genero = 'J','Jurídica','-')) as fisica_juridica,
				cpf_cnpj as cpf_cnpj,
				DATE_FORMAT(data_atendimento, '%d/%m/%Y') as data_atendimento,
				sise,
				cc.descricao as nome_produto,
				se.descricao as servico,
				su.descricao as sub_servico,
				cidade,
				uf,
				mo.motivo as motivo,
				de.descricao as origem_problema,
				bp.descricao as base_prestador,
				enviado_por as agente,
				DATE_FORMAT(enviado_dpto_em, '%d/%m/%Y %H:%i:%s') as enviado_dpto_em,
				DATE_FORMAT(resposta_dpto_em, '%d/%m/%Y %H:%i:%s') as resposta_dpto_em,
				responsavel,
				acoes_dpto,
				comentarios,
				parecer,
				DATE_FORMAT(recebido_em, '%d/%m/%Y %H:%i:%s') as recebido_em,
				DATE_FORMAT(respondido_em, '%d/%m/%Y %H:%i:%s') as respondido_em,
				

Open in new window

0
Hi Experts

Couls you point a way to make Codeigniter to consider the UTF-8 characters in config.php?

// Actually using
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';

//I'm trying to avoid to accept every character here - only UTF-8
//$config['permitted_uri_chars'] = '';

Open in new window


Thanks in advance!
0
I like learning object oriented php

but do not want to be bogged down by html, css, jquery, javascript, ajax

I know I can use command line php but if a client is paying me; client usually wants artwork.
A css designer will draw a picture of an expected form and I am forced CODE the html and css to the exact layout of the picture

then the client states the the textbox is 1 inch (.5 cm) too tall.



do other object oriented languages force me to learn so much design software


Please add many other object oriented programming zones
0
Hi Experts


Could you point how to correctly present an array already obtained from CodeIgniter's model in the View?

Controller's code:
$this->data['fk_seguradora_f'] = $this->seguradora_model->get_seguradoras();

Open in new window


Model's Code:
function get_seguradoras( ) 
{ 
	$fk_seguradora_f = array();

	$query=$this->db->query("SELECT id_seguradora, nome_seguradora FROM system_seguradora");
	$fk_seguradora_f = $query->result_array();

	return $fk_seguradora_f;
}

Open in new window


View's code
<div class="row">
	<div class="col-xs-12 mb15">
		<div class="input-group">
			<span class="input-group-addon ">
				<i class="fa fa-search c-gray"></i>
			</span>
			<!--EF Jan/2017 - Campo de filtro dinamicamente formado --->
			 <span class="select">
				 <select id="fk_seguradora" name="fk_seguradora">
						<?php
						
                                               var_dump('testeyyy'); // just to locate the code easily.
						var_dump($fk_seguradora_f);
						die;
						
						
						foreach($fk_seguradora_f as $each)
						{
						?>
							<option value="<?=$each['id_seguradora']?>"><? echo $each['nome_seguradora']?></option>
						<?php
						}
						?>
				</select>
			  </span>
		</div>
	</div>
</div>

Open in new window


Debbuging, the array is correctly obtained in the view:
img001
The combo is functional but the names (nome_seguradora) doesn't appears.

img002Could you point a workaround on this?

Thanks in advance!
0
Introducing the "443 Security Simplified" Podcast
LVL 1
Introducing the "443 Security Simplified" Podcast

This new podcast puts you inside the minds of leading white-hat hackers and security researchers. Hosts Marc Laliberte and Corey Nachreiner turn complex security concepts into easily understood and actionable insights on the latest cyber security headlines and trends.

Hi Experts

Could you point a way to form a view's combo based on Codeigniter's results?

Accordingly to:

Controller's code:
public function index() {

	// SELECT/DROPDOWN - Seguradora
	$fk_seguradora = $this->cliente_corporativo_model->new_get(array('query' => 'select * from system_seguradora'));
	$dropdown[0] = 'Selecione ...';
	foreach ($fk_seguradora as $key => $value)
		$dropdown[$value->id_seguradora] = $value->nome_seguradora;

	$this->data['fk_seguradora'] = form_dropdown('fk_seguradora', $dropdown, '', 'id="id_seguradora"');
	unset($dropdown);
	
	...

Open in new window



View's code:
The values are actually "hard coded"
  <div class="row">
	<div class="col-xs-12 mb15">
		<div class="input-group">
			<span class="input-group-addon ">
				<i class="fa fa-search c-gray"></i>
			</span>
			<span class="select">
				<select id="fk_seguradora" name="fk_seguradora">
					<option value="" selected="selected">...Cliente Corporativo...</option>
					<option value="1">Ace</option>
					<option value="2">Zurich</option>
					<option value="3">Banco Safra</option>
					<option value="4">SANTANDER</option>
					....
				</select>
			</span>
		</div>
	</div>
</div>

Open in new window


I tryed to do this way:
<div class="row">
	<div class="col-xs-12 mb15">
		<div class="input-group">
			<span class="input-group-addon ">
					<i class="fa fa-search c-gray"></i>
			</span>
			<span class="select">
				<select id="fk_seguradora" name="fk_seguradora">
				
                                  // A for-each at this point makes sense?? - I guess there is a better option.
				   <option value="<?php $id_seguradora?>"><?$fk_seguradora?></option>
 
						
				</select>
			</span>
			</label>
		</div>
	</div>
</div>

Open in new window


Thanks in advance!
0
Hi Experts

Could you possibly give a help on how to configure Datatables plugin to make it correctly runs?

It's a Codeigniter project.
View code
<?php
             //datatables is a Codeigniter helper
		echo datatables(
				array(
			'id_servico' => 'ID',
			'descricao' => 'Descrição',
			  'acoes' => 'Ações',
                        // These lines must receive fake values otherwise Datatables doesn't load
			'a' => '',
			'b' => '',
			'c' => '',
			'd' => '',
			'e' => '',
			'f' => '',
		  
				),
				// Options dataTables
				array(
			'id' => 'datatables',
			'width' => '100%',
			'controller' => 'servico',
			'action' => 'datatables_list',
				),
				array(
			'like' => array(
				 'descricao'
			),
			'where' => array(
				'descricao'
			),
			'search_submit' => '.pesquisar_groups_form',
				)
		);

?>

Open in new window


Relevant part of datatables helper where the Datatable plugin is configured:
function redrawDataTables(where) {

	if (typeof table != "undefined" && typeof table != undefined && table != "") {

		$("#exemplo").empty();
		table.destroy();
	}

	if (typeof where == "undefined" || typeof where == undefined) {
		where = "";
	}
	   
	table =  $("#' . $options['id'] . '").DataTable({
		"paging":   true,
		// "pagingType": "scrolling",
		"pagingType": "full_numbers",
		// "sPaginationType": "four_button",
		"retrieve": true,
		"searching": false,
		"ordering": true,

		"order": [
			[ 
				' . $order . ', "' . $order_type . '"
			]
		],

		

Open in new window

0
I am trying to redirect the page when I click on "goback" button. Since I already have an ajax call when I click on "submit" button, I went ahead to add ajax call to "goback" button. I want to redirect the page when I click on "goback" with the data from controller. I am able to see the next page with all the data I need to display in the console, but unable to actually navigate the page. I know that ajax is expecting a response for the request it has sent but I am stuck with the navigation part. Also I am using codeigniter.
I have posted my code below.


view:


 
 <form name="uploadFile" method="post" enctype="multipart/form-data" id="upload-form">
 <p>
<div class="input-files">
  <?php
  foreach ($results as $row) {
   ?>
            <label for="methodname">Method Name:</label>
  <input type="radio" name="taskid" checked="true" id="taskid" value="<?php echo $row->taskid; ?>"/><?php echo $row->taskname; ?><br>
              <input type="radio" name="methodfields" checked="true" id="methodfields" value="<?php echo $row->methodid; ?>"/><?php echo $row->methodname; ?><br>
            <?php } ?>
 </p>
  <b>Step</b><input type="text" name="step" id="step"/><br/>
  <b>Image</b>
  <input type="file" accept="image/png, image/jpeg, image/gif" name="message" id="message" />
</div>
 <input type="button" value="Send Comment" id="submit" name="submit">
   <input class="form-control" type="button" value="Go Back" id="goback" name="goback">
  <ul id="comment"></ul>

Open in new window

0
Not a question, just a heads-up to the E-E community.  PHP 5 is circling the drain, with active support continuing only 21 more days at this writing.  Time to upgrade to PHP 7+
http://php.net/supported-versions.php

Of particular importance is the removal of MySQL, which has been deprecated for years.  More information here:
https://www.experts-exchange.com/articles/11177/PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html

If your PHP framework or application depends on any version of PHP < 7.0, you may have a sudden load of technical debt, and a difficult decision to make.
1
Hi Experts

Could you point why this Codeigniter's data insertion is causing an error?

if ($this->db->insert("server_routes", $params)) {
	return $this->db->insert_id();
} else {
	return false;
}

Open in new window


Thanks in advance!

The $params array:
array(9) { ["id"]=> string(0) "" ["_name"]=> string(3) "xxx" ["_hostname"]=> string(14) "192.168.100.76" ["_port"]=> string(4) "5060" ["_providerId"]=> string(2) "13" ["_prefix"]=> string(5) "65019" ["_active"]=> string(1) "1" ["_channel"]=> string(3) "120" ["_description"]=> string(0) "" }

Open in new window


The MySQL table structure where the data must to be inserted:

CREATE TABLE server_routes (
  id int(11) NOT NULL DEFAULT 0,
  _name varchar(150) DEFAULT NULL,
  _hostname varchar(45) DEFAULT NULL,
  _port int(11) DEFAULT NULL,
  _providerId int(11) DEFAULT NULL,
  _prefix varchar(15) DEFAULT NULL,
  _active int(11) DEFAULT NULL,
  _channel int(11) DEFAULT 30,
  _description text DEFAULT NULL
)
ENGINE = INNODB
AVG_ROW_LENGTH = 327
CHARACTER SET latin1
COLLATE latin1_swedish_ci;

Open in new window

0
I am getting the above error and I am really not sure where I am going wrong. I am using Codeigniter framework. Following is my code:

Controller:

public function createtask()
      {
      
  $this->load->model('persona_model');
    $data['persona']=$this->persona_model->view();
                  $this->load->view('createtask_view', $data);
            }

Model:

function view()
      {
          $this->db->select('*');
          $this->db->from('persona');
          $query = $this->db->get();
          if($query->num_rows()>0){
          return $query->result();
          }else{
              return $query->result();
          }
      }


view:
                <table class="table">
                <thead>
              <tr>
                <th>Persona ID </th>
                <th>Firstname </th>
                <th>Lastname</th>
                </tr>
                </thead>
                <tbody>
                  <?php
                  foreach($persona as $row)
                {
                      ?>
                      <tr>
                      <td><?php echo $row->personaid; ?></td>
                      <td><?php echo $row->firstname; ?></td>
                      <td><?php echo $row->lastname; ?></td>
                  <?php      }
                  ?>
                   </tbody>


Kindly help I have been looking into this since a long time.
0

CodeIgniter

36

Solutions

52

Contributors

Top Experts In
CodeIgniter
<
Monthly
>

No Top Experts for this time period. Answer questions to earn the title!