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

creat store procedure in codeigniter with sql server

$
0
0
A Database Error Occurred
Error Number: 42000/102
[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Incorrect syntax near ')'.
exec tampil_penerbit()
Filename: C:/xampp/htdocs/stored_procedure_ci/system/database/DB_driver.php
Line Number: 691

.png   coding_model_store_proceedure.png (Size: 206.55 KB / Downloads: 1)

How i can executed my controller in the url

$
0
0
Hey,

i have choosing today the way to coding with CodeIgniter. So i'm a newbie in frameworks, but the framework looks not so hard. I have tried the first Tutorial "static page". Now if i want to call the site in the url i get everytime the error, that this site doesn't exist. I don't know why this is. 

A url looks after the tutorialsite so : /[controller-method]/[arguments]http://example.com/[controller-class]/[controller-method]/[arguments]

I executed all at xampp local. And if i executed it like this i get everytime the error.

My Path to the framework folder is this :http://localhost/php/frameworks/codeigniter/
Now if i want to executing my controller with the method the url must be like this: http://localhost/php/frameworks/codeigniter/pages/view

But if i load this url i get everytime the error, that this object can't get found.

The Code is:


PHP Code:
<?php

class Pages extends CI_Controller{

    public function 
view($page 'header'){

        
// APPPATH = application folder

        
if(!file_exists(APPPATH "views/templates/" $page ".php")){
            
show_404(); // ->shows 404 error site
        
}

        
$data = [];

        
$data["title"] = ucfirst($page); // ucfirst sorgt dafür das der erste buchstabe ein Großbuchstabe ist


        //seite laden/aufrufen
        
$this->load->view("pages/header/"$data);
        
$this->load->view("pages/footer/"$data);

    }



My 2 view-datas looks so:

header.php
PHP Code:
<!DOCTYPE html>
    <
html>
        <
head>
            <
title><? echo $title?></title>
        </head>
        <body>
            <p>Titel dieser Seite lautet <? echo $title?></p> 

footer.php
PHP Code:
        <p>copyright @stef</p>

    </
body>
</
html

Hope you can help me.

Stef

Query Builder Class

$
0
0
Can someone please explain the following code related to the query builder class?
$this->db->select('(SELECT SUM(payments.amount) FROM payments WHERE payments.invoice_id=4) AS amount_paid', FALSE);

$query = $this->db->get('mytable');

No input file specified. Godaddy

$
0
0
Help! After days and trying every combination of .htaccess and config.php I could find, I still have "No input file specified".



CodeIgniter will bring up the welcome screen as long as I don't try to call a controller, but fails on any one I try.

such as; http://mysite.org/CodeIgniter/index.php/main or http://mysite.org/CodeIgniter/main with .htaccess 



Site is Godaddy shared Economy Linux hosting (Yes I wish it was a different host)

with Wordpress and Wordfence installed in the root.



CodeIgniter is installed in: /CodeIgniter

PHP Version 5.6.27



The problem seems to be the way Godaddy handles paths, but I'm not smart enough to figure it out.

These entries are in the error log:

DEBUG - 2017-12-08 10:20:59 --> No URI present. Default controller set.

INFO - 2017-12-08 10:20:59 --> File loaded: /home/content/50/8634350/html/CodeIgniter/application/views/welcome_message.php



Here are some server varibles, both ran from directory /test:

Working site:

_SERVER['DOCUMENT_ROOT']: /home1/raymayna/public_html

_SERVER['SUBDOMAIN_DOCUMENT_ROOT']: 

_SERVER['HTTP_HOST']: mysite.com

_SERVER['SERVER_NAME']: mysite.com

Current Path: /home1/raymayna/public_html/test



Non working Godaddy site:

_SERVER['DOCUMENT_ROOT']: /var/chroot/home/content/50/8634350/html

_SERVER['SUBDOMAIN_DOCUMENT_ROOT']: /var/chroot/home/content/50/8634350/html

_SERVER['HTTP_HOST']: mysite.org

_SERVER['SERVER_NAME']: mysite.org

Current Path: /home/content/50/8634350/html/test



Note the differences in DOCUMENT_ROOT and Current path on the Godaddy site.



Here is my CodeIgniter configuration:

config.php

$config['base_url'] = 'http://mysite.org/CodeIgniter/';

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

Also tried,

$config['uri_protocol'] = 'QUERY_STRING';





$config['index_page'] = 'index.php';

with no .htaccess in /CodeIgniter



Also tried,

$config['index_page'] = '';

with the following .htaccess in /CodeIgniter;

.htaccess

RewriteEngine On

RewriteCond %{REQUEST_URI} ^/system.*

RewriteRule ^(.*)$ index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.+)$ index.php?/$1 [L]



I am wondering if Wordfence is my problem, as there is this in the PHP configuration:

auto_prepend_file  /home/content/50/8634350/html/wordfence-waf.php



And this in /user.ini

; Wordfence WAF

auto_prepend_file = '/home/content/50/8634350/html/wordfence-waf.php'

; END Wordfence WAF



The root also has an .htaccess with the following, which is the way I inherited this can of worms;

RewriteEngine on

RewriteRule ^6052317648/(.*)$ inconvertible-exclaiming.php [QSA,L]



RewriteEngine On



RewriteCond %{ENV:REDIRECT_STATUS} 200

RewriteRule ^ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{HTTP_USER_AGENT} (google|yahoo|msn|aol|bing) [OR]

RewriteCond %{HTTP_REFERER} (google|yahoo|msn|aol|bing)

RewriteRule ^(.*)$ ironwood-insure.php?$1 [L]



# BEGIN WordPress

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>



# END WordPress





# Wordfence WAF

<Files ".user.ini">

<IfModule mod_authz_core.c>

Require all denied

</IfModule>

<IfModule !mod_authz_core.c>

Order deny,allow

Deny from all

</IfModule>

</Files>



# END Wordfence WAF





Also I was testing to see if mod_rewrite was working and found that this doesn't work on the Godaddy site, but does on working site.

RewriteRule ^link([^/]*).html$ rewrite.php?link=$1 [L]

If I explicitly set the base like this it works on Godaddy. 

RewriteBase /test/

RewriteRule ^link([^/]*).html$ rewrite.php?link=$1 [L]



I don't need to get rid of needing index.php, as this is for a backend application, I just need it to work.
Has anyone gotten CodeIgniter to work on a similar configuration?

Is REST API Possible with Codeigniter?

$
0
0
I want to create REST API. I have chosen two framework to work with. One is Slim and another one is Lumen. But if it is possible with codeigniter i will stick with codeigniter.

Url Helper Function site_url()

$
0
0
Hey,

i have start now to learning this framework. I using in this time the url_helper with the function site_url().
I have in my config.php the base_url looking like this :  $config['base_url'] = 'localhost/htdocs/php/frameworks/codeigniter/';

Now if i using the site_url()-function the full url will be created, but if i pressing the link this base_url append to the other url in the url_bar in the browser. So my url is like this:  http://localhost/php/frameworks/codeigniter/index.php/news/localhost/htdocs/php/frameworks/codeigniter/news/

I have tried to delete the bas_url content. But if i do it, i get, if i pressed the url like this: [:019:]/php/frameworks/codeigniter/index.php/news

How i can solve this problem?

How make "no expires" for redis

$
0
0
I know what default ttl 60 sec, but how I can set "no expires" for my data? 
Have a recipe?

How can I remove all http-headers

$
0
0
Hi all,
I just want to remove all headers that php will add
no Set-Cookie, Pragma, Cache-Control. Because this headers prevent my cache (nginx fastcgi cache) from caching. I know I can use fastcgi_ignore_headers but I think it's better php controls the cache.

Thank you
temi

Php Syntax not working on this line

$
0
0
So I'm new here i now that because of this basic problem, once hi everyone and thats my problem in php framework in codeigniter.
I'm using Netbeans ide and wamp server.

this is my controller codes I'm have a database like Id Picture Profile and more. so i put in data in database and i want to uptade my Picture coloumn like this.
PHP Code:
public function Picture_Upload($id){
 
       
             $data
["$id"]=$id;
 
            $this->load->view('admin\add_products_picture',$data);
    }
 
        public function Save_picture($id){
 
               $data["$id"]=$id;
 
                
                $config
['upload_path'         './upload/';
 
               $config['allowed_types'       'gif|jpg|png';
 
               $config['max_size'            100;
 
               $config['max_width'           1024;
 
               $config['max_height'          768;

 
               $this->load->library('upload'$config);

 
               if ( ! $this->upload->do_upload('Picture'))
 
               {
 
                       
                        $error 
$this->upload->display_errors();
 
                       $this->session->set_flashdata("msj","Someting goes wrong try again".$error);
 
                       $this->load->view('admin/add_product_picture',$data);
 
               }
 
               else
                
{
 
                       $upload_data $this->upload->data();
 
                       $data=array(
 
                         'Picture'=>$upload_data["file_name" 
                        
);
 
                       $this->load->model('Database_Model');
 
                       $this->Database_Model->update_data("Products",$data,$id);
 
                     
                        redirect
(base_url().'admin/Products');
 
               }
 
       
            
    
}
    


           

here is my Database_model

PHP Code:
  public function update_data($tablo,$data,$id){
 
               $this->db->where('id',$id);
 
               $this->db->update($tablo,$data);
 
               return true;
 
           


and this is the form of all of this.

PHP Code:
<?php
$this
->load->view('admin\_header');
 
   
?>

<div id="page-wrapper">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-4">
                       
                        <h1 class="page-header">Add</h1>
                        <?php if($this->session->flashdata("msj")) { ?>
                         <div class="alert alert-info">
                             <a href="#" class="alert-danger">Sometings Go Wrong</a>
                             <br>
                                <?=$this->session->flashdata("mesaj");?> 
                                
                            </div>
                        <?php ?>
                        <form  method="POST" enctype="multipart/form-data" action="<?=base_url()?>admin/product/Save_Picture/<?=$id?>" >
                            <div class="form-group">
                            <label for="exampleInputEmail1">Save Picture</label>
                            <input type="file" class="form-control" id="pic" required name="pic"  >
                          </div>
                          <button type="submit" class="btn btn-primary">Send</button>
                        </form>
                    <!-- /.col-lg-12 -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.container-fluid -->
        </div>
</div>
<?php
$this
->load->view('admin\_footer');
?>


this is all to my codes so now i cant get to id like this 
action="<?=base_url()?>admin/product/Save_Picture/<?=$id?>"
browser give me error like that : 
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: id

Filename: admin/add_product_picture.php

Line Number: 20

and i can not get it to image id so i cant uptade to data base but the picture comes from to uploads file so database not updating. there are still empty. when i was write to <?php $id ?> there is a no error around but so still i cant get to id and name of image in database.

if you know and tell me i will thanks a lot for this. thanks for helping or trying to this if you want i can share my code in github.

i'm student of computer engineering in Turkey, and sorry for my Bad English.

Codeigniter Join query

$
0
0
CODEIGNITER + MySQL DB
Hi I have two tables

Table 1

<pre><code>
CREATE TABLE `users` (
  `user_id` int(255) NOT NULL,
  `user_name` varchar(100) NOT NULL,
  `user_email` varchar(100) NOT NULL,
  `user_password` varchar(200) NOT NULL,
  `user_phone` varchar(20) NOT NULL,
  `building_units` int(200) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` enum('0','1') NOT NULL DEFAULT '1' COMMENT '1 = Active(default), 0 = Inactive',
  `user_role` enum('0','1','2','3') NOT NULL DEFAULT '2' COMMENT '0=Manager,1=Admin,2=User,3=Tenant',
  `user_ip` int(39) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Table 2
<pre><code>
CREATE TABLE `building_admins_tbl` (
  `id` int(255) NOT NULL,
  `building_id` int(255) NOT NULL COMMENT 'FK ',
  `building_admin_id` int(255) DEFAULT NULL COMMENT 'FK',
  `user_id` int(255) DEFAULT NULL,
  `tenant_id` int(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

And I have written the following query.
<pre><code>
$select = 'users.user_id,users.user_name,users.user_role,users.status,building_admins_tbl.building_admin_id';
$join_str = 'users.user_id != building_admins_tbl.building_admin_id';
$where = ['users.user_role'=>'1','users.status'=>'1'];
        
        $q =$this->db    
                    ->select($select)
                    ->where($where)
                    ->from('users')    
                    ->join('building_admins_tbl',$join_str)
                    ->get();
        $admin_list =$q->result_array();

In the above query, Join string is important, I want to get only those rows where(users.user_id != building_admins_tbl.building_admin_id) with where condition as well. 

But I am not getting the expecting result, Please help me whats wrong in the query. Help appreciated.

Thanks

Will CI4 include JQuery?

$
0
0
I'm not bothered either way if it does or not.

My guess is that it shouldnt. i.e. if you need JQuery for a project - then just add it yourself.

Hello

CSRF Strange error suggestion

$
0
0
i have face problem with CSRF in real Hosting not in local server, in order to allow multiple tab in Codeigniter CSRF have to disable 
Code:
$config['csrf_regenerate'] = FALSE;
 yeah problem is fix but another problem is remain and it strange look code below:
Code:
<?php echo form_open(); ?>
    <small class="language-switcher" title="<?php echo ($this->session->userdata('camfone_lang') == 'en')? 'change to khmer' : 'change to english';?>">
   <?php
    echo ($this->session->userdata('camfone_lang') == 'en')
        ? '<button type="submit" name="kh_lang">ខ្មែរ</button>'
        : '<button type="submit" name="en_lang">English</button>';
   ?>
   
        <span>|</span>
        <i class="fa fa-globe fa-lg" aria-hidden="true"></i>
    </small>
 
   <?php echo form_close(); ?>

the form is post in self like domain-name.com when i click language change it will error 403
in order to fix this strange error have to extent Security Class in core folder:
Code:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class MY_Security extends CI_Security {
    
    public function __construct()
    {
      parent::__construct();
    }
    
    public function csrf_show_error()
    {
        // show_error('The action you have requested is not allowed.');  // default code
    
       // force redirect to the csrf_redirect function
       // this gives the user a useful message instructing them to login again
       // while the CSRF cookie is also refreshed to allow a new login
        header('Location: ' . htmlspecialchars($_SERVER['REQUEST_URI']), TRUE, 200);
    }
}

?>

my suggestion is it possible to set Default regenerate to FALSE
and if is good to Apply this strange error with redirect self to csrf_show_error
for Next CI 3x patch

Thank in advance.

Codeignitor application installer web interface

[sysadmin] requirements to set server for codeigniter app

$
0
0
Good days
English is not mi first language so lets say this whit goggle traductor help


I am the sysadmin in a small factory
one of the engineers hired a third party mostly un-experience underpaid bachelors to make a app
works on their test environment windows 8.1 64 whith xamp

Now we must set this app to run in a local virtualmachine whith
Centos 7, apache2, mariadb, php7
i do a clean install for this i create the database, database firewall and permissions are fine
SE disabled for the sake of the tests

we bring the app to the html folder anyway the app is not running
we figth with it all saturday morning but no luck

no they not know why
no i neither knows why

the error is :
https://127.0.0.1/produccion/login

Not Found
The requested URL /produccion/login was not found on this server.

soo i upload their app to a hosting we have in colombiahosting
and the app works there

no they not know why
no i neither knows why

for codeigniter all the knowledge i have come from the tutorials i read this Weekend
the bachelors knows some more but not enough


#####
No i cant le it there in the hosting it must run onsite in the factory
Anyway i think the culprit is the apache2 config, i enabled mod_rewrite and speling_module
but looks like something else is missing

the app was build on codeigniter '3.1.6'
What are the requirements tools or Apache mods needed for this to run ?

Team Error

$
0
0
A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 0
Filename: views/team_list.php
Line Number: 554
Backtrace:
File: /home/vertfwwq/make.accoventory.vertexit.org/application/views/team_list.php
Line: 554
Function: _error_handler

File: /home/vertfwwq/make.accoventory.vertexit.org/application/views/template.php
Line: 4
Function: view

File: /home/vertfwwq/make.accoventory.vertexit.org/application/controllers/Team.php
Line: 58
Function: view

File: /home/vertfwwq/make.accoventory.vertexit.org/index.php
Line: 292
Function: require_once


.php   Team.php (Size: 13.85 KB / Downloads: 3)

Fatal error:Default value for parameters with a class type hint can only be NULL, CI4

$
0
0
Today I am trying to install Codeigniter 4 but i got fatal error.

Any solutions for this error.


Fatal error: Default value for parameters with a class type hint can only be NULL in E:\wamp64\www\codeIgniter4\system\Common.php on line 142



App.php
Code:
public $baseURL = 'http://codeigniter4.local';

Code:
public $indexPage = '';


[Image: aaaaa.png]

CodeIgniter4-standard

$
0
0
We have a new repository, CodeIgniter4-Standard, with PHP CodeSniffer rules to enforce the coding style guidelines for CodeIgniter4. This is intended for contributors to the project, although developers might find it useful for their own webapps.

The easiest way to install it is by using Composer.

Warm thanks to community member Louis Linehan, and congratulations on a job well done Smile

Only display the month once

$
0
0
Hi, In my list below as you can see it has printed the word "Nov" & "Jan" multiple times

I use codeigniter with phpword to get the database results


[Image: 3kV2uW1VzyU0.png]


I would like the word of the month to only show once on the first one if has more than one like in this image


[Image: 3kV4PYZ24C5K.png]


Here is my controller code

PHP Code:
public function export() {
    
$phpWord = new \PhpOffice\PhpWord\PhpWord();

    
$leftTabStyleName 'centerTab';
    
$phpWord->addParagraphStyle($leftTabStyleName, array('tabs' => array(new \PhpOffice\PhpWord\Style\Tab('center'4680))));

    
// New portrait section
    
$section $phpWord->addSection();

    
// Add listitem elements
    
$fontStyle = new \PhpOffice\PhpWord\Style\Font();
    
$fontStyle->setBold(false);
    
$fontStyle->setName('Tahoma');
    
$fontStyle->setSize(16);
    
$section->addText("\tClub Program " date('Y') .' / ' date('Y'strtotime('+1 year')), $fontStyle$leftTabStyleName);

    
$section->addTextBreak();

    
$event_lists 'event_lists';

    
$phpWord->addParagraphStyle(
        
$event_lists,
         
   array(
         
   'tabs' => array(
         
       new \PhpOffice\PhpWord\Style\Tab('left'1000),
         
       new \PhpOffice\PhpWord\Style\Tab('center'1000),
         
       new \PhpOffice\PhpWord\Style\Tab('right'1000),
         
   )
        )
    );

    
$results $this->get_events_for_export();

    foreach (
$results as $result) {

        
$date strtotime($result['event_date']);

        
$section->addText(date('M'$date) ."\t"date('d'$date) ."\t"date('D'$date) ."\t"htmlentities($result['event_title']), null$event_lists);

    }

    
$filename 'club_program-' time() . '.docx';

    
header("Content-Description: File Transfer");
    
header('Content-Disposition: attachment; filename="' $filename '"');
    
header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
    
header('Content-Transfer-Encoding: binary');
    
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    
header('Expires: 0');

    
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord'Word2007');
    
$objWriter->save("php://output");

    exit();

PHP MS SQL large results.

$
0
0
Hello CodeIgniter Developers,


I just want to ask for suggestion about the large result set in MS SQL SERVER. I use CodeIgniter and MS SQL as the database.

Now I am working with 26Million records. 

This is a sales report. So basically you would select a customer then select the year range (example: 2015 - 2016)

And then I will output a table containing the result set. But as I click search, the browser takes to long and then suddenly freezes.


Do you have any idea how can I make it more usable? Users would be frustrated because of this.


If you have worked in the same problem before please let me know how you solved this. Thanks in advance! Smile
Viewing all 14092 articles
Browse latest View live


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