Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all 14136 articles
Browse latest View live

hello codeigniter ... some help me

$
0
0
I am getting this error once i auto -load session. i installed apache and dropped codeigniter into htdocs folder ... when i auto load the session library i an getting that error

.png   Capture.PNG (Size: 51.05 KB / Downloads: 7)

apache, php and codeigniter error

$
0
0
I installed codeigniter in apache htdocs folder, i am getting the following error when i auto load session library.

.png   Capture.PNG (Size: 51.05 KB / Downloads: 10)

Query builder - like() with wildcard within a string

$
0
0
Hi,

I know I can use wildcards on the beginning and end of the string, but I can't figure out how (or if) I can use it withing the string.

I know how $this->db->like() works:
PHP Code:
$this->db->like('title''match');  //produces WHERE `title`LIKE '%match%' 

but sometimes I need to match just one charachter with "_" withing the match string or something more custom
PHP Code:
WHERE `titleLIKE 'ma_ch'
WHERE `titleLIKE 'ma%h%' 

Thanks

Logging insert and update queries via hook

$
0
0
Hi there! as per title said.. how I can log and profile the insert and update query for my CI application?

Loading Uri segements in config.php

$
0
0
I have been trying to use on my config.php


PHP Code:
require_once(BASEPATH .'core/URI.php');

$URI = new CI_URI(); 

On my config.php for my sessions

PHP Code:
$config['sess_driver'] = 'files';

if (
$URI->segment(1) == 'admin') {

    
$config['sess_cookie_name'] = 'admin_sessions';
    
$config['sess_expiration'] = 1440;
    
$config['sess_save_path'] = FCPATH 'application/cache/session/admin/';

} else {

    
$config['sess_cookie_name'] = 'catalog_sessions';
    
$config['sess_expiration'] = 7200;
    
$config['sess_save_path'] = FCPATH 'application/cache/session/catalog/';

}

$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE

But comes up with this error

Code:
A PHP Error was encountered

Severity: Notice

Message: Use of undefined constant UTF8_ENABLED - assumed 'UTF8_ENABLED'

Filename: core/URI.php

Line Number: 328

Backtrace:

File: C:\xampp\htdocs\project-1\application\config\config.php
Line: 371
Function: __construct

File: C:\xampp\htdocs\project-1\index.php
Line: 315
Function: require_once

Is there a better way so I can use URI segments in config.php

Form field with dynamic id validation

$
0
0
How can i validate fields with names like this


Code:
<select name="mechanic_134" id="mechanic-134" class="form-control selectpicker">


mechanic_ is the general field name &  134 is a id i am getting from database. there are more fields to come like mechanic_135........mechanic_150.


i want to know how can i validate this field with dynamic id. please show it in code level. how it is done in controller & how the error output in view

Thanks.

[split] View Layout? (CodeIgniter4 Roadmap - Phase 2)

$
0
0
Add Layout option for view. It would be very useful.

Exlude particulary areas from the cache

$
0
0
Hi,

is it possible to exclude some specific areas from the cache? As an example, i want to show an historylist at the bottom of the page. This area should not be cached. How can i do this?

Edit Pages

$
0
0
How to fix this error message?

A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: views/editpages.php
Line Number: 49
Backtrace:
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\views\editpages.php
Line: 49
Function: _error_handler
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\controllers\Cpages.php
Line: 269
Function: view
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\index.php
Line: 315
Function: require_once



Line 49: 

PHP Code:
<?php foreach ($pages as $pages_item): ?>


views/editpages.php


PHP Code:
<?php //$pages=array(); ?>
                    
                    <?php foreach ($pages as $pages_item): ?>
                    
                    <div class="widget-box">
                        <div class="widget-title"><h5>Pages</h5></div>
                        <div class="widget-content">
                        
                        <?php echo form_open('cpages/editpagesupdate'); ?>
                        <table border="0" style="width: 100%; height: 90px;">
                            <tr>
                                <td>Pages Name</td>
                                <td><input type="text" name="pages_name" value="<?php echo $pages_item['pages_name']; ?>"></td>
                            </td>
                            <tr>
                                <td>Create Date</td>
                                <td><input type="text" name="create_date" value="<?php echo $pages_item['create_date']; ?>"></td>
                            </td>    
                            <tr>
                                <td>Order</td>
                                <td><input type="text" name="pages_order" value="<?php echo $pages_item['pages_order']; ?>"></td>
                            </td>
                            <tr>
                                <td>View Content</td>
                                <td><textarea rows="3" cols="20" name="pages_content"><?php echo $pages_item['pages_content']; ?></textarea></td>
                            </td>
                            <tr>
                                <td></td>
                                <td><input type="submit" class="edit" name="submit" value="SUBMIT"></td>
                            </tr>
                        </table>            
                        </div>
                    </div>        

                    <?php endforeach; ?>
                    
                </div>
            </div> 

Styling anchor

$
0
0
Hello,

I have a question about style this CI codes.  How to style the link ID, Content Name, etc.

I would like to take off the underline and change the font color into black.  I already try to add css to <td> and it does not change the font.  I know css but do not know how to integrate it with CI codes.  Please help.

views/contents.php


PHP Code:
<table border="0" style="width: 100%; height: 90px;">
                            <tr>
                                <td><?php echo anchor('''ID'); ?></td>
                                <td><?php echo anchor('''CONTENT NAME'); ?></td>
                                <td><?php echo anchor('''CREATE DATE'); ?></td>
                                <td><?php echo anchor('''EDIT'); ?></td>
                                <td><?php echo anchor('''DELETE'); ?></td>    
                            </tr> 

CodeIgniter doesn't work with an MS Access database

$
0
0
Hi,
 
I'm new to PHP and CodeIgniter and I'm having troubles with the sample application in the Tutorial chapter of the CodeIgniter manual.
It doesn't work with an MS Access database. I managed to connect to it, but exactely the statements for selecting and inserting records into it (in the News_model.php) don't work.

The database connection settings are like:
PHP Code:
$db['default'] = array(
    
'dsn' => 'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=C:\Users\Dinu\Desktop\TestDB.accdb',
    
'hostname' => 'localhost',
    
'username' => 'Dinu',
    
'password' => '',
    
'database' => '',
    
'dbdriver' => 'odbc',
 
    ...
); 

My News_model.php is this:
PHP Code:
<?php
class News_model extends CI_Model {

 
   public function __construct()
 
   {
 
       $this->load->database();
 
   }

 
   public function get_news($slug FALSE)
 
   {
 
       if ($slug === FALSE)
 
       {
 
          // $query = $this->db->get('news');
 
               // Err: Call to undefined method CI_DB_odbc_driver::get()
 
          $query $this->db->query('SELECT * FROM news');
 
               // This is good
 
          
           
return $query->result_array();
 
       }

 
       // $query = $this->db->get_where('news', array('slug' => $slug));
 
           // Err: Call to undefined method CI_DB_odbc_driver::get_where()
 
       // $query = $this->db->query('SELECT * FROM news WHERE slug = "' . $slug . '"');
 
           // Err: SQL error: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1
 
       $query $this->db->query('SELECT * FROM news', array('slug' => $slug));
 
           // This allways gets only the first news, regardless of what the slug is.

 
       return $query->row_array();
 
   }

 
   public function set_news()
 
   {
 
       $this->load->helper('url');

 
       $slug url_title($this->input->post('title'), 'dash'TRUE);

 
       $data = array(
 
           'title' => $this->input->post('title'),
 
           'slug' => $slug,
 
           'tecst' => $this->input->post('tecst')
 
       );
 
       
        
// return $this->db->insert('news', $data);
 
           // Err: Call to undefined method CI_DB_odbc_driver::insert()
 
       // return $this->db->query('INSERT INTO news (title, slug, tecst) VALUES ("' .
 
                               // $this->input->post('title') . '", "' .
 
                               // $slug . '", "' .
 
                               // $this->input->post('tecst') . '")');
 
           // Err: SQL error: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 3
 
       return $this->db->query('INSERT INTO news (title, slug, tecst) VALUES (s, s, s);'$data);
 
           // Err: SQL error: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1
 
   }


And the database is attached.

How to get from a database that has less than 2 rows

$
0
0
Hi,

I am trying to figure out how I can get a result from the database that has the following criteria:

check only the records of this month (I know this part)
that has <2 rows in user_id
and where the date == to the same ones

Sorry, I am finding it hard to explain.

I want to get the total number of rows in myTable that has only 1 row for each user_id with the same date.

I will try to figure out how to explain this better if needed.

Doomie

CI 2.1.4 + MS SQL 2012

$
0
0
I got problem with run application wrote in CI 2.1.4 with MS SQL 2012.
So I'm using PHP v 5.6.23, I add sqlsrv driver to ext folder, I'm trying to run app on XAMPP (Apache).
And I got error like:
Code:
A PHP Error was encountered
Severity: Warning
Message: sqlsrv_query() expects parameter 1 to be resource, boolean given
Filename: sqlsrv/sqlsrv_driver.php
Line Number: 152
A PHP Error was encountered
Severity: Warning
Message: sqlsrv_query() expects parameter 1 to be resource, boolean given
Filename: sqlsrv/sqlsrv_driver.php
Line Number: 152

Fatal error: Call to a member function num_rows() on boolean in C:\xampp\htdocs\project-web\src\resources\system\libraries\Session.php on line 216


In logs folder I got:

Code:
ERROR - 2016-08-28 15:40:39 --> Unable to connect to the database
ERROR - 2016-08-28 15:40:39 --> Unable to connect to the database
ERROR - 2016-08-28 15:40:39 --> Severity: Warning  --> sqlsrv_query() expects parameter 1 to be resource, boolean given C:\xampp\htdocs\prompt-web\src\resources\system\database\drivers\sqlsrv\sqlsrv_driver.php 152
ERROR - 2016-08-28 15:40:39 --> Severity: Warning  --> sqlsrv_query() expects parameter 1 to be resource, boolean given C:\xampp\htdocs\prompt-web\src\resources\system\database\drivers\sqlsrv\sqlsrv_driver.php 152
ERROR - 2016-08-28 15:40:39 --> Unable to connect to the database
ERROR - 2016-08-28 15:40:39 --> Severity: Warning  --> sqlsrv_query() expects parameter 1 to be resource, boolean given C:\xampp\htdocs\prompt-web\src\resources\system\database\drivers\sqlsrv\sqlsrv_driver.php 152
ERROR - 2016-08-28 15:40:39 --> Severity: Warning  --> sqlsrv_query() expects parameter 1 to be resource, boolean given C:\xampp\htdocs\prompt-web\src\resources\system\database\drivers\sqlsrv\sqlsrv_driver.php 152



Could any body give me ideas why I get this errors?
I was trying a lot of solutions from stacoverflow, I also tryied this http://forum.codeigniter.com/thread-63060.html
but I got already ODBC driver installed, so please give me your suggestions.

UserGuide notation

$
0
0
Reading this page in the UG:

https://bcit-ci.github.io/CodeIgniter4/general/views.html

I note that there is a code segment which shows something I am NOT familiar with;  a variable ($data) is assigned using notation which might be an array, but I've never seen this notation:


Code:
class Page extends \CodeIgniter\Controller
{
       public function index()
       {
               $data = [
                       'page_title' => 'Your title'
               ];

               echo view('header');
               echo view('menu');
               echo view('content', $data);
               echo view('footer');
       }
}


Should this actually read:

Code:
...
$data = array('page_title' => 'Your title');
...


Or is this using a "shorthand" php array declaration?
Yes, I have looked at the PHP 7 documentation, but do not find this type of assignment for an array.

route system

$
0
0
i want to route like this

ex: 

http://localhost/index.php/user/USERNAME_FROM_MYSQL



PHP Code:
class Host extends CI_Controller {


public function ?()
{

}


Trying to get property of non-object

$
0
0
Hello,

I am facing another error message here:



A PHP Error was encountered

Severity: Notice

Message:  Trying to get property of non-object

Filename:  views/pcategories.php

Line Number: 58

Backtrace:  

File: C:\Program Files\EasyPHP\www\CompanyGiondaCI\application\views\pcategories.php

Line: 58

Function: _error_handler

http://127.0.0.1/CompanyGiondaCI/index.p...tparentctg';">EDIT

------------------------------------------------

views/pcategories.php


PHP Code:
<?php foreach ($posts as $post): ?>
                            
                            <tr>
                                <td><?php echo $post['ctgparent_name']; ?></td>
                                <td><?php echo $post['ctgparent_description']; ?></td>
                                <td><button type="button" class="edit" onclick="location.href='<?php echo site_url('cpages/editparentctg/'.$post->ctgp_no); ?>';">EDIT</button></td>
                                <td><button type="button" class="delete" onclick="location.href='<?php echo site_url('cpages/editparentctg/'.$post->ctgp_no); ?>';">DELETE</button></td>    
                            </td>    
                                                                                    
                            <?php endforeach; ?>

line 58: 

<td><button type="button" class="edit" onclick="location.href='<?php echo site_url('cpages/editparentctg/'.$post->ctgp_no); ?>';">EDIT</button></td>

controllers/cpages.php

PHP Code:
public function pcategories() { 
    
            
        
$data['posts'] = $this->Mpages->call_parentctg();

        
//$data['ctgparent_name'] = $this->Mpages->call_parentctg();
        //$data['ctgparent_description'] = "Second";//$this->Mpages->retrieve_parentctg();
        
        
$this->load->view('pcategories'$data); 


models/Mpages.php

PHP Code:
public function call_parentctg()
    {
        
        
$query $this->db->get('menu_parent');
        return 
$query->result_array();
                        
    } 


How to fix the error message?

Is Bonfire any good?

$
0
0
Before I get to far into investigating it, what are the pros and cons of Bonfire?

The pros for me so far are:
  1. 1. Email queue
  2. 2. User Auth.

What are the cons of Bonfire?

global_xss_clean

$
0
0
So I'm setting up a site using 3.1.0, I've set one up using CI 3.0.0 in the past, and I noticed that in the config it says global_xss_clean is deprecated. Is XSS cleaning going away in completely or just global_xss_clean will there be global sanitation?

Basically, what I'm asking is how will this affect CI once it's removed entirely?

codeigniter Support Forum Ticket System

$
0
0
Hey, everyone I am building a website  using codeigniter still have some way to go but looking for some people to test it and report bugs. 
its a Forum and  Ticket System in one.

Welcome to share feedback its something simple but will grow over time 

you can join here http://www.sftsystem.com/user/login and i'll change  your staus from user to admin after if you ask

Thank you

Empty storage procedures

$
0
0
Hi, I have a problem about mysql stored procedures that i can't resolve, i tried a lot of configurations with mysqli_next_result free_result reconnect and nothing works.

The function getListProds($listID) is inside of foreach so it be called several times.

When I run the code I get all data as empty (0 rows). I find no solution. I've tried a lot of things. Right now I have the following:


It seems to all times returns first query result ( that is empty )

PHP Code:
   public function getListProds($listID){
 
       $superID 0;
 
       $query $this->db->query("CALL getList('".$listID."',".$superID.")");
 
       mysqli_next_result$this->db->conn_id );

 
       $num_rows $query->num_rows();
 
       $datas $query->result_array();

 
       if($num_rows == 0){
 
           return null;
 
       }else{
 
           return $datas;
 
       }
 
   



Thanks for all.
Viewing all 14136 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>