PHP CodeIgniter Error: Undefined Property [Generate Qrcode] - php

Hi im new to using additional libraries on codeigniter (im using this library) so these error are really overwhelming me, the goal im trying is to make a form input with option tag (the options from my db) then when i click the button, it will automatically generate the qrcode. at first im following some tutorial from the internet and adjust some parts in order to reach the actual goal.
It doesnt show any explicit error on the html page so i checked the console of the page the error as follows;
jquery-3.4.1.js:9837 POST http://localhost/ikanku/Make_qr/save 500 (Internal Server Error)
send # jquery-3.4.1.js:9837
ajax # jquery-3.4.1.js:9434
(anonymous) # make_qr:421
dispatch # jquery-3.4.1.min.js:2
v.handle # jquery-3.4.1.min.js:2
so im trying to open the network tab to see if there anything that i could fix anything, but it confuse me bcs the error show as following;
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Make_qr::$Ciqrcode
Filename: core/Model.php
Line Number: 73
Backtrace:
File: C:\xampp\xampp\htdocs\ikanku\application\models\Make_qr_model.php
Line: 35
Function: __get
File: C:\xampp\xampp\htdocs\ikanku\application\controllers\Make_qr.php
Line: 24
Function: save
File: C:\xampp\xampp\htdocs\ikanku\index.php
Line: 315
Function: require_once
ive been load the model name, controllers name globally through the autoload and internally through parent::__construct(); but it still error as above, i really need anyone's suggestion/advice for my problem because im still learning on how to make a qrcode feature in my application.
Right now im using CodeIgniter 3.1.11
heres my controller - Make_qr.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Make_qr extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('Make_qr_model');
}
public function index()
{
$data['vessel'] = $this->db->query('select * from vessel order by vessel_name')->result_array();
$data['port'] = $this->db->query('select * from port order by port_name')->result_array();
$this->load->view('template/header');
$this->load->view('template/sidebar');
$this->load->view('qrcode/make_qr',$data);
$this->load->view('template/footer');
}
public function save()
{
$this->Make_qr_model->save($this->input->post());
}
}
heres my model - Make_qr_model.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Make_qr_model extends CI_Model {
function __construct()
{
parent::__construct();
$this->load->library('Ciqrcode');
}
function random_strings($length_of_string){
$str_result = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; //abcdefghijklmnopqrstuvwxyz
return substr(str_shuffle($str_result),0, $length_of_string);
}
//save data function setelah qrcode di generate
public function save($data){
$data = array_replace($data,
array_fill_keys(
array_keys($data, ""),
NULL
)
);
if(isset($data['quantity']) && count($data['quantity'])>0){
for($i=1;$i<=$data['quantity'];$i++){
$r = $this->random_strings(6);
$this->load->library('Ciqrcode');
$config['cacheable'] = true;
$config['cachedir'] = './assets/';
$config['errorlog'] = './assets/';
$config['imagedir'] = './assets/images/';
$config['quality'] = true;
$config['size'] = '1024';
$config['black'] = array(224,255,255);
$config['white'] = array(70,130,180);
$this->Ciqrcode->initialize($config);
$image_name=$r.'.png'; //buat name dari qr code sesuai dengan random string
$params['data'] = $r; //data yang akan di jadikan QR CODE
$params['level'] = 'H'; //H=High
$params['size'] = 1024;
$params['savename'] = FCPATH.$config['imagedir'].$image_name; //simpan image QR CODE ke folder assets/images/
$this->Ciqrcode->generate($params); // fungsi untuk generate QR CODE
$img = file_get_contents(FCPATH.$config['imagedir'].$image_name, "r");
$base64 = 'data:image/png;base64,'.base64_encode($img);
$data_insert = array();
$data_insert['vessel_id'] = $data['vessel_id'];
$data_insert['port_id'] = $data['port_id'];
$data_insert['key'] = $r;
$data_insert['qr'] = $base64;
$this->db->insert('qr_vessel', $data_insert);
$vessel = $this->db->query('select * from vessel where id='.$data['vessel_id'])->row_array();
echo "<table class='table table-striped m-table'>
<tbody>
<tr>
<td width='30%' style='background-color:black'>
<img src=".$base64.">
</td>
<td width='70%' style='vertical-align:top'>
Vessel Name : ".$vessel['vessel_name']."<br>
Vessel Company : ".$vessel['company']."<br>
Fishing Gear : ".$vessel['fishing_gear']."<br>
</td>
</tr>
<tr>
<td align='center'>
".$r."
</td>
<td align='center'></td>
</tr>
</body>
</table>";
}
$notif['x'] = 'ok';
}else{
$notif['x'] = 'error';
die('error');
}
return;
}
}
?>
and heres my view - make_qr.php
<section class="content">
<form role="form" name="frm" action="<?=site_url('Make_qr/save')?>" method="post" id="frm">
<div id="container">
<h1>Generate Fishing QR</h1>
<div id="body">
<table class="table table-striped m-table">
<tbody>
<tr>
<td>Vessel</td>
<td>
<select id='vessel_id' name='vessel_id' style="width:250px" >
<option value="">Pilih</option>
<?php
foreach($vessel as $row){
?>
<option value="<?=$row['id_vessel']?>"><?=$row['vessel_name']?> - <?=$row['company']?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Port Departure</td>
<td>
<select id='port_id' name='port_id' style="width:250px" >
<option value="">Pilih</option>
<?php
foreach($port as $row){
?>
<option value="<?=$row['id_port']?>"><?=$row['port_name']?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td>QR Quantity</td>
<td>
<select id='quantity' name='quantity'>
<option value="">Pilih</option>
<?php
for($i=1;$i<=20;$i++){
?>
<option value="<?=$i?>"><?=$i?></option>
<?php
}
?>
</select>
</td>
</tr>
</tbody>
</table>
<div class="col-lg-3 m--margin-bottom-10-tablet-and-mobile">
<span id='loading' style="display:none"><img src="<?php echo base_url(); ?>Assets/assets/images/ajax-loader_dark.gif"></span>
<button type="button" class="btn btn-info" id="save">Generate</button>
</div>
<br>
<div id='qrs'></div>
</div>
</section>
i apologize for the long description of my errors it would be mean so much to me if i can get some advice & suggestion from here,
thankyou

Change model name Make_qr_model to Makeqr_model
Load library $this->load->model('Makeqr_model');
Load CodeIgniter-PHP-QR-Code library properly; clone git repo and paste folder inside application/libraries
Make sure GD2 PHP extension installed
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class QRGenerator extends CI_Controller {
function __construct(){
Parent::__construct();
}
public function generate(){
$this->load->library('ciqrcode');
$params['data'] = 'This is a text to encode become QR Code';
$params['level'] = 'H';
$params['size'] = 10;
$params['savename'] = FCPATH.'tes.png';
$this->ciqrcode->generate($params);
echo '<img src="'.base_url().'test.png" />';
}
}
Codeigniter model reference click
Hope it will help you

Related

Codeigniter - Pagination undefined function

i have a function to show data from controller like this :
public function leaderboards()
{
if($this->ion_auth->logged_in()){
$leaderboard = $this->FrontModel->getLeaderboard();
$dataLeaderboard = ''; $no = 1;
foreach ($leaderboard as $row) {
$dataLeaderboard .='
<tr class="calculate-price-wrapper post">
<td>
<div class="mv-font-secondary mv-f-14"><strong>'.$no.'.</strong></div>
</td>
<td>
<div class="mv-font-secondary mv-f-14"><strong>'.$row['fname'].'</strong></div>
</td>
<td >
<div class="mv-font-secondary mv-f-14"><strong>'.$this->replace_character($row['email']).'</strong></div>
</td>
<td>
<div class="mv-font-secondary mv-f-14"><strong>'.$row['total_point'].'</strong></div>
</td>
</tr>
';
$no++;
}
/* pagination */
$config = array();
$config["base_url"] = base_url(). "leaderboards";
$config["total_rows"] = count($dataLeaderboard);
$config["per_page"] = 20;
$config["uri_segment"] = 3;
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data['dataLeaderboard'] = $dataLeaderboard($config["per_page"], $page);
$data['pagination'] = $this->pagination->create_links();
/* data template - header footer */
$template['menuActive'] = 'leaderboard';
$template['menuLoggedIn'] = $this->menuLoggedIn;
$this->load->view('front-end/template/header', $template);
$this->load->view('front-end/leaderboard', $data);
$this->load->view('front-end/template/footer', $template);
}else{
redirect('auth', 'refresh');
}
}
And here is the my view :
<!-- .main-breadcrumb-->
<section class="mv-main-body cart-main mv-bg-gray mv-wrap">
<div class="container">
<div class="latest-blog-title mv-title-style-3 no-text-behind" style="padding-bottom:30px;">
<div class="title-3-text"><span class="main">LEADERBOARD</span></div>
<div class="title-3-line"></div>
</div>
<div class="cart-inner">
<div class="cart-block block-cart-table mv-bg-white mv-box-shadow-gray-1 mv-mb-50">
<div class="mv-table-responsive">
<table class="mv-table-style-2">
<thead>
<tr>
<th style="width:15%;">Pos.</th>
<th style="width:30%;">Name</th>
<th style="width:30%;">Email</th>
<th style="width:20%;">Point</th>
</tr>
</thead>
<tbody>
<?=$dataLeaderboard?>
</tbody>
</table>
<div class="mv-pagination-wrapper mv-mt-25 mv-mb-25">
<div class="mv-pagination-style-1 has-count-post">
<?php echo $pagination; ?>
</div>
<!-- .mv-pagination-style-1-->
</div>
</div>
</div>
</div>
</div>
</section>
but it ended up having an error like this :
Fatal error: Call to undefined function <tr class="calculate-price-wrapper post"> <td> <div class="mv-font-secondary mv-f-14"><strong>1.</strong></div> </td> <td> <div class="mv-font-secondary mv-f-14"><strong>Test Name</strong></div> </td> <td > <div class="mv-font-secondary mv-f-14"><strong>te*s*n*ame*g*ai*.c*m</strong></div> </td> <td> <div class="mv-font-secondary mv-f-14"><strong>55</strong></div> </td> </tr> <tr class="calculate-price-wrapper post"> <td> <div class="mv-font-secondary mv-f-14"><strong>2.</strong></div> </td> in C:\xampp5.6\htdocs\motogp2022\application\controllers\front-end\MainController.php on line 703
A PHP Error was encountered Severity: Error
Message: Call to undefined function
Test Name
tesnamegai.c*m 55
Filename: front-end/MainController.php
Line Number: 703
Backtrace:
And the line that cause the error was this line in my controller :
$data['dataLeaderboard'] = $dataLeaderboard($config["per_page"], $page); //Line 703
anyone know solution for this? anyhelp is really appreciated, thank you!.
In this line:
$data['dataLeaderboard'] = $dataLeaderboard($config["per_page"], $page);
You are using $dataLeaderboard as a function. You are setting it as a string of HTML, hence you're getting that the HTML does not exist as a function.
Not knowing your full code, but what I think you need to do is:
Not create the leaderboard data as a single string, but rather as an array of HTML (so not $dataLeaderboard .= ... but rather $dataLeaderboard[] = ....
Then do $data['dataLeaderboard'] = $dataLeaderboard. For brevity, you can in your loop directly set it into an array $data['dataLeaderboard']. You will not set it as $dataLeaderboard(...). The round bracket around the variable means you're trying to use the variable as a function, which it is not.
For full implementation of the pagination library in CI, check this manual page: https://codeigniter.com/userguide3/libraries/pagination.html. There is a specific set configuration options and code lines that must be present, and your pagination library must be loaded, of course.
There might be more to do after that, but start there.

PHP Fatal error: Call to a member function result_array() on a non-object

I am working on php using codeigniter framework as a beginner. My program is running perfectly on my localhost. But after uploading to the web server, it is showing an error for some pages. I have searched about this problem and most of the solutions show that my program is right. But for the live server, it is showing PHP fatal error. First one is, whenever I want to see data in datatable it is showing HTTP 500 error. My server administrator told me this is because of my model whenever I am returning data as result_array(). Here is my model,
public function get_pages()
{
$this->db->select('*');
$this->db->from('page');
$this->db->join('NavigationMenu', 'NavigationMenu.MenuID = page.MenuID', 'left');
$this->db->join('SubMenu', 'SubMenu.SubMenuID = Page.SubMenuID', 'left');
$query = $this->db->get();
return $query->result_array();
}
Here is my controller for that,
public function pages()
{
$data['page'] = $this->Pages_Model->get_pages();
$tempString = $this->load->view('admin_panel/content/pages', $data, true);
$page_data = array(
'fileHere' => $tempString
);
$this->load->view('admin_panel/shared/admin_layout',$page_data);
}
And this is my View page,
<!-- Main content -->
<div class="box">
<div class="box-header">
<h3 class="box-title">Page Lists</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<table id="page_table" class="table table-bordered table-striped">
<thead>
<tr>
<th>Title</th>
<th>Main Menu</th>
<th>Sub-Menu</th>
<th>Edit/Remove</th>
</tr>
</thead>
<tbody>
<?php foreach ($page as $page_item): ?>
<tr>
<td><?php echo $page_item['PageTitle']; ?></td>
<td><?php echo $page_item['MenuName']; ?></td>
<td><?php echo $page_item['SubMenuName']; ?></td>
<td><button type="submit" class="btn btn-primary" onClick="javascipt:window.location.href='<?php echo base_url('content/edit_page_content')?>/<?php echo $page_item['PageID']; ?>'">Edit</button>
<button type="submit" class="btn btn-danger delete_page" id="<?php echo $page_item['PageID']; ?>">Remove</button></td></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<!-- /.box-body -->
</div>
<!-- /.content -->
This is one of my problem. I beleive if I get a solution I can solve others. The result_array() function is working perfectly in other places like where I need to fetch data. Thank you in advance.
Try This as controller,
public function pages()
{
$data['page'] = $this->Pages_Model->get_pages();
$this->load->view('admin_panel/content/pages',$data);
$this->load->view('admin_panel/shared/admin_layout',$data);
}
</pre>
My database is case-sensitive. This is the reason it is showing that error. I have modified my model and it works now.
public function get_pages()
{
$this->db->select('*');
$this->db->from('Page');
$this->db->join('NavigationMenu', 'NavigationMenu.MenuID = Page.MenuID', 'left');
$this->db->join('SubMenu', 'SubMenu.SubMenuID = Page.SubMenuID', 'left');
$query = $this->db->get();
return $query->result_array();
}

CakePHP: Error: The view for TasksController::index() was not found

I use CakePHP 2.5.5 . My project in this directory: C:\xampp\htdocs\vy\cakephp-2.5.5 . My project directory layout:
I have been created file C:\xampp\htdocs\vy\cakephp-2.5.5\app\Model\task.php (Model)with content:
<?php
class Task extends AppModel
{
var $name = 'Task';
}
?>
I have been created file C:\xampp\htdocs\vy\cakephp-2.5.5\app\Controller\TasksController.php (Controller) with content:
<?php
class TasksController extends AppController
{
var $name = 'Tasks';
function index()
{
$this->set('tasks', $this->Task->find('all'));
}
}
?>
I have been created file C:\xampp\htdocs\vy\cakephp-2.5.5\app\View\Task\index.ctp (View) with content:
<h2>Tasks</h2>
<?php if (empty($tasks)): ?>
There are no tasks in this list
<?php else : ?>
<table>
<tr>
<th>Title</th>
<th>Status</th>
<th>Created</th>
<th>Modified</th>
<th>Actions</th>
</tr>
<?php foreach ($tasks as $task): ?>
<tr>
<td>
<?php echo $task['Task']['title'] ?>
</td>
<td>
<?php
if ($task['Task']['done']) echo "Done";
else echo "Pending";
?>
</td>
<td>
<?php echo $task['Task']['created'] ?>
</td>
<td>
<?php if ($task['Task']['modified']) ?>
</td>
<td>
<!-- actions on tasks will be added later -->
</td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
When run program, error:
Missing View
Error: The view for TasksController::index() was not found.
Error: Confirm you have created the file: C:\xampp\htdocs\vy\cakephp-2.5.5\app\View\Tasks\index.ctp
Notice: If you want to customize this error message, create app\View\Errors\missing_view.ctp
How to repair above application? Thank you!
All you have to do is read the error message carefully :)
The view folder should be View\Tasks (plural) instead of View\Task as you currently have.
Also your model file name should be Task.php not task.php. Be carefully of case sensitivity in file names. While things will work on windows if you move files to a linux server you will get errors as it has case sensitive filesystem.

Sortable columns Joomla

I'm developing a MVC component for Joomla! 2.5 and I want to add some sortable columns in my backend. For this goal I've tried to do the next:
http://docs.joomla.org/Adding_sortable_columns_to_a_table_in_a_component
And I got an error "View not found [name, type, prefix]". In this case I have looking for a solution and I find the next:
http://forum.joomla.org/viewtopic.php?p=2638695
Following those indications I have removed the "action" of my "form". In this case my column is sortable, but another problem arises. If I remove the "action" of my "form" then "edit buttom" of my toolbar does not work.
I think there must be another solution because I need working "edit buttom" and sortable column also. I've looking for some similar question here and I've applied the following information:
How to add sortable columns in a Joomla component (table), both ASC and DESC with an arrow
&
Joomla 2.5 -Adding sortable columns to a table in a component
But my problem persits. What can I do?? Thank you.
MY RELEVANT SOURCE CODE IS THE NEXT:
com_inscripciones/admin/models/anuals.php
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the Joomla modellist library
jimport('joomla.application.component.modellist');
/**
* Inscripciones List Model
*/
class InscripcionesModelAnuals extends JModelList
{
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'nombre',
'fecha_nac',
'reserva'
);
}
parent::__construct($config);
}
protected function populateState($ordering = null, $direction = null)
{
parent::populateState('id', 'asc');
}
/**
* Method to build an SQL query to load the list data.
*
* #return string An SQL query
*/
protected function getListQuery()
{
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('id,nombre,apellidos,nif,fecha_nac,reserva,validacion,clave');
// From the hello table
$query->from('#__anual');
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering', 'nombre')).' '.$db->escape($this->getState('list.direction', 'ASC')));
return $query;
}
}
?>
com_inscripciones/admin/views/anuals/view.html.php
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla view library
jimport('joomla.application.component.view');
/**
* Anuals View
*/
class InscripcionesViewAnuals extends JView
{
/**
* display method of Inscripciones view
* #return void
*/
function display($tpl = null)
{
// Get data from the model
$items = $this->get('Items');
$pagination = $this->get('Pagination');
$state = $this->get('State');
$this->sortDirection = $state->get('list.direction');
$this->sortColumn = $state->get('list.ordering');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode('<br />', $errors));
return false;
}
// Assign data to the view
$this->items = $items;
$this->pagination = $pagination;
// Set the toolbar
$this->addToolBar();
// Display the template
parent::display($tpl);
}
/**
* Setting the toolbar
*/
protected function addToolBar()
{
JToolBarHelper::title(JText::_('Inscripciones Manager: Curso Anual'), 'inscripciones');
JToolBarHelper::spacer('10');
JToolBarHelper::divider();
JToolBarHelper::spacer('10');
JToolBarHelper::editList('anual.edit');
JToolBarHelper::spacer('10');
JToolBarHelper::divider();
JToolBarHelper::spacer('10');
JToolBarHelper::deleteList('¿Desea eliminar esta inscripción?', 'anuals.delete');
JToolBarHelper::spacer('20');
}
}
?>
com_inscripciones/admin/views/anuals/tmpl/default.php
<?php
// No direct access
defined('_JEXEC') or die('Restricted access');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.multiselect');
?>
<form action="<?php echo JRoute::_('index.php?option=com_inscripciones&view=anuals$layout=default'); ?>"method="post" name="adminForm"id="inscripciones-form">
<table class="adminlist">
<thead>
<tr>
<th width="5">
<?php echo JText::_('ID'); ?>
</th>
<th width="20">
<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($this->items); ?>);" />
</th>
<th>
<?php echo JHtml::_('grid.sort', 'NOMBRE', 'nombre', $this->sortDirection, $this->sortColumn); ?>
</th>
<th>
<?php echo JText::_('APELLIDOS'); ?>
</th>
<th>
<?php echo JText::_('NIF'); ?>
</th>
<th>
<?php echo JHtml::_('grid.sort', 'FECHA NAC.', 'fecha_nac', $this->sortDirection, $this->sortColumn); ?>
</th>
<th>
<?php echo JHtml::_('grid.sort', 'RESERVA', 'reserva', $this->sortDirection, $this->sortColumn); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="3"></td>
</tr>
</tfoot>
<tbody>
<?php foreach ($this->items as $i => $item): ?>
<tr class="row<?php echo $i % 2; ?>">
<td>
<?php echo $item->id; ?>
</td>
<td>
<?php echo JHtml::_('grid.id', $i, $item->id); ?>
</td>
<td>
<?php echo $item->nombre; ?>
</td>
<td>
<?php echo $item->apellidos; ?>
</td>
<td>
<?php echo $item->nif; ?>
</td>
<td>
<?php echo $item->fecha_nac; ?>
</td>
<td>
<?php echo $item->reserva; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="filter_order" value="<?php echo $this->sortColumn; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $this->sortDirection; ?>" />
<?php echo JHtml::_('form.token'); ?>
</div>
My query line in model looks like
$query->order($db1->getEscaped($this->getState('list.ordering', 'ordering')).' '.$db1->getEscaped($this->getState('list.direction', 'ASC')));
and populateState contains
$orderCol = JRequest::getCmd('filter_order', 'ordering');
$this->setState('list.ordering', $orderCol);
and the construct on the filter_fields contains
$this->_order[] = JRequest::getVar('filter_order', 'fieldName', 'POST', 'cmd');
$this->_order[] = JRequest::getVar('filter_order_Dir', 'asc', 'POST', 'word');
I had some trouble getting these working in some views in a component I made, just a lot of combinations of things that can be wrong, but you'll get there. I used this tutorial
http://docs.joomla.org/J2.5:Developing_a_MVC_Component/Introduction
I guess you have already found the bug, but for everyone else, based on the provided code:
<form action="<?php echo JRoute::_('index.php?option=com_inscripciones&view=anuals$layout=default'); ?>" ...>
This line is wrong. Your view call is &view=anuals$layout=default.
Correct would be &view=anuals&layout=default
The only reason why you got that view error.
Please mark my answer as correct if that was you problem back in 2014.

Link to a Controller function with parameter from a View (CodeIgniter)

Using CodeIgniter I am trying to create a link that the user can click within a view to show them the details of a record in my database.
In ASP.NET MVC3 with C# I would do it with #Html.ActionLink("Controller", "Action", new { id = item.Id})
This is my session controllers index() function
public function index()
{
$data['sessions'] = $this->session_model->get_sessions();
$this->load->view('_header');
$this->load->view('session/index', $data);
$this->load->view('_footer');
}
This is the index view it loads where I want to be able to click the link to go to enter() function
<table>
<th>Session Name</th>
<th>Description</th>
<th>Host</th>
<th></th>
<?php foreach ($sessions as $session_item): ?>
<tr>
<td> <?php echo $session_item['sessionName'] ?> </td>
<td> <?php echo $session_item['sessionDesc'] ?> </td>
<td> <?php echo $session_item['adminName'] ?> </td>
<td> <a id="enterSession" href=<?php echo site_url("session/enter" + $session_item['id']) ?> >Enter</a></td>
</tr>
<?php endforeach ?>
The enter session points me to the url "http://192.168.1.36/index.php/1" (if the id of my item is 1) whereas I expect "http://192.168.1.36/index.php/session/enter/1"
Any ideas on how I can make it call the enter() function also in the session controller (shown below)
public function enter($id) {
$this->load->view('_header');
$this->load->view('session/enter');
$this->load->view('_footer');
}
There seems to be a typo in the string concatenation in your PHP code. Perhaps it will work to use:
site_url("session/enter" . $session_item['id'])
... rather than a + sign between the two strings.
Regarding the second question - it looks correct as-is. Is it failing to call the session controller's enter() function passing the $id as an argument (assuming the URL is correct)?.

Categories