Welcome Guest, Not a member yet? Register   Sign In
  routing and subfolder problem
Posted by: El Forum - 10-31-2007, 12:54 PM - Replies (1)

[eluser]easymind[/eluser]
I have:

Code:
in: controllers/ttt
file: welcome.php
a function:
function test($var1=false,$var2=false,$var3=false)
{
    echo $var1;
    echo $var2;
    echo $var3;
}

this url: http://xxx.xx/ttt/welcome/test/1/2/3
generates: 123

then a routing: $route["en/(.*)"] = "$1";
and this url: http://xxx.xx/en/ttt/welcome/test/1/2/3
generates: test12

So somehow the position of the arguments to the subfoldered function are not routed correctly, or I need to use a different syntax. What is the problem here?

Code:
$route["english/(:any)"] = "$1";
gives the same bad argument values

$route["english/(:any)"] = "/$1";
works good but gives 404 if controller is in a subfolder

I even noticed that putting folders inside a folder in your controller (so if you go 2 deep) you always get a 404 without routing...


  Problem with validation & radios
Posted by: El Forum - 10-31-2007, 11:45 AM - Replies (1)

[eluser]Unknown[/eluser]
Hi

Yes. I'm kinda new to CodeIgniter as you'll see, but I'm having a big problem with validation of radios.

1. If I have a form with only radios in it, I can't get any validation to work. i.e <?=$this->validation->error_string;?> will not show anything on error
2. If I have more (text) field, <?=$this->validation->error_string;?> will appear, but the individual errors will appear, but not for the radios.

Have I missed something huge here? - Probably.

Example controller:

Code:
<?php

/**
*  Testing how the form validation stuff works
*
*/

class Test extends Controller {

    function __construct()
    {
        parent::Controller();
        
        $this->load->helper(array('form', 'string','url'));    
        $this->load->library(array('validation'));
    }

    function index()
    {

        // validation info
        $rules['review'] = 'trim|required|min_length[1]|max_length[10]';
        $rules['review_name'] = 'trim|min_length[5]|max_length[10]';
        $this->validation->set_rules($rules);

        $fields['review'] = 'Review Id';
        $fields['review_name'] = 'Review name';
        $this->validation->set_fields($fields);
        
        $this->validation->set_error_delimiters('<br/><em>[', ']</em>');
        
        $data = array(); // Empty array    
        if ($this->validation->run() == FALSE)
        {
    
            // Load the review setup "Choose/Setup review" page (with validation messages when required)
            $this->load->view('test', $data);    
        }
        else
        {
            // Add a new review event
            $this->load->view('test_success', $data);            
        }
    }        
}

?&gt;

View:
Code:
<h2>Test/Example CI form validation</h2>

&lt;?=$this->validation->error_string;?&gt;


&lt;?=form_open('test'); ?&gt;

    <p>
        review_id &lt;input type="radio" name="review" value="abc" &lt;?= $this-&gt;validation->set_radio('review', 'abc'); ?&gt; /><br/>
        review_id &lt;input type="radio" name="review" value="def" &lt;?= $this-&gt;validation->set_radio('review', 'def'); ?&gt; />
        &lt;?=$this->validation->review_error; ?&gt;
    </p>
        
    <p>
        review_name &lt;input type="text" name="review_name" value="&lt;?=$this-&gt;validation->review_name?&gt;" />
        &lt;?=$this->validation->review_name_error; ?&gt;
    </p>
        
    <p class="formFooter">
        &lt;input type="reset" value="reset" /&gt;
        &lt;input type="submit" value="&lt;?=$this-&gt;lang->line('button_next')?&gt;" />
    </p>

&lt;/form&gt;

I can't get &lt;?=$this->validation->review_error; ?&gt; to output anything.

Where am I going wrong?

Cheers
RH


  Class referencing appears a memory leak
Posted by: El Forum - 10-31-2007, 10:53 AM - Replies (7)

[eluser]dyron[/eluser]
Hi,

now I'm develop for a while with CI. Nice Framework, but still some places for improvements.

After I work on a handball website, my system ran low and my browser crashed. Looking at the task manager shows me a storage allocation of 900MB! for firefox and 300MB! for apache. This isn't normal.

For debugging I created a helper which contains:

Code:
function debug()
{
  echo "<pre>\n";
  var_dump(func_get_args());
  echo "</pre>\n";
  die();
}

I used this for displaying $this. This was a experience.
Firebug notifies that this HTTP request causes 200MB traffic before arriving the PHP maximum_execution_time of 30 secs.
Most of the "$this" content was absolutely redundant, e.g. more than 50 CI_Config references.

Does anybody know, how I kept $this thin and clean?
I think it's a problem with
Code:
$CI =& get_instance();
in functions or
Code:
$this->CI =& get_instance();
in classes.

I use PHP 5, however I read & is deprecated. Should I use
Code:
$CI = get_instance();
instead?

My CI version is 1.5.4.

Anybody noticed such characteristics?

Regards dy


  escaping null values
Posted by: El Forum - 10-31-2007, 08:27 AM - Replies (11)

[eluser]ken_t[/eluser]
hi, i just started working with frameworks and im not a pro php programmer.
So i dont know if im doing something wrong.

In my application i have a function that insert at a db some values from the view input fields.
There are some int type fields at this table as for example the age field.

Im using $this->db->insert(table,values) function.

And when i leave the age input field null and submit the form, the escape function treats it as string and escape it.

Then i get a db error saying invalid value for int "".

I edited the escape function at db_driver.php to make it not escape null values. Is there another way for it?


  Problem with the controller url
Posted by: El Forum - 10-31-2007, 06:56 AM - Replies (3)

[eluser]tirithen[/eluser]
How come

"http://visarkiv.hinfitt.se/index.php?blog" works and
"http://visarkiv.hinfitt.se/index.php/blog" does not

Would this be a setting on the web-server? Unfortunently it's a commercial server so I can't change any settings.


  Unable to locate the model
Posted by: El Forum - 10-31-2007, 05:57 AM - Replies (3)

[eluser]Jim-Bingo[/eluser]
When I load my firstpage I get this message:

Quote:An Error Was Encountered

Unable to locate the model you have specified: startmodel

My controller start.php:
Code:
&lt;?php
class Start extends Controller {
        
    function index()
    {
          $this->load->model('startmodel');
          $news['news'] = $this->startmodel->get_last_three_news();
          $data = array(
               'title' => 'Malungs OK SkogsmÃ¥rdarna',
               'content' => $this->load->view('content/start',$news,true)
          );
  
          $this->load->view('layout/main',$data);
    }
        
}
?&gt;

My model Startmodel.php:

Code:
&lt;?php
class Startmodel extends Model {

    function Startmodel()
    {
         parent::Model();
    }
    
    function get_last_three_news()
    {
        $query = $this->db->get('tbl_news', 3);
        return $query->result();
    }
    
}
?&gt;

Anybody knows whats wrong?


  Email over SMTP is sent, but CI returns false
Posted by: El Forum - 10-31-2007, 04:12 AM - Replies (2)

[eluser]Daniel Kvasnicka jr.[/eluser]
Hi people,
CI is a wonderful thing, I switched from CakePHP and I like the way CI does not stand in my way and yet it serves me with many useful classes.

However, I have a weird problem with sending e-mail over SMTP. The email is sent, but CI's send() method returns FALSE. The first problem is, that it shows SMTP's 220 Service ready response as an error (with "The following SMTP error was encountered" before it). And the second problem is "354 Enter mail, end with "." on a line by itself". Is this some kind of incompatibility between CI's mail class and some mailservers' specific configs? (ESMTP Sendmail 8.13.6/8.13.6.)

Message sent was:

Code:
User-Agent: CodeIgniter
Date: Wed, 31 Oct 2007 11:08:45 +0100
From: "dan"
Return-Path:
To: [email protected]
Subject: Test mail
Reply-To: "[email protected]"
X-Sender: [email protected]
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <[email protected]>
Mime-Version: 1.0


Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Testing

(the real address was exchanged for "[email protected]" so that crawlers don't find it here)


  AdBrite/AdSense clone
Posted by: El Forum - 10-31-2007, 12:09 AM - No Replies

[eluser]Unknown[/eluser]
Hello. First of all hi everybody. I'm new to CI (like month of watching through manuals, examples etc). And I'm here to get some help if possible =)

So, as you probably can see from the topic I'm working on an AdBrite/AdSense clone. And the main question now is - has anyone got some examples of how to write such thing using CI? Of course I can do it myself to ... But just thought that I'll post here and see if someone can help =)

Any help is much appreciated. Thank you.


  Interesting Load of CI from an external class
Posted by: El Forum - 10-30-2007, 10:26 PM - No Replies

[eluser][email protected][/eluser]
Hey guys, I am trying to load the CI framework from an external class. The framework is loading fine with no errors in the logs.

I am trying two scenarios here, and for scenario #1, am getting result: "12"

&lt;?php
require_once('../../../simpletest/unit_tester.php');
require_once('../../../simpletest/reporter.php');
require_once('../../../index.php'); //Load CI Framework

class admin_model_test extends UnitTestCase {

function testGetAllDesigns() {

echo '1';
$CI =&get;_instance();
echo'2';
$CI->load->model('admin_model');
echo '3';
$arr = $CI->admin_model->getAllDesigns();
echo '4';
$this->assertTrue(true);
echo '5';
}
}

if(TESTING=='TESTING') {
$test = & new admin_model_test();
$test->run(new HtmlReporter());
}
?&gt;

For scenario #2 (comment out CI stuff), I am getting "12345", and then the test case result.

&lt;?php
require_once('../../../simpletest/unit_tester.php');
require_once('../../../simpletest/reporter.php');
require_once('../../../test_index.php');

class admin_model_test extends UnitTestCase {

function testGetAllDesigns() {

echo '1';
//$CI =&get;_instance();
echo'2';
//$CI->load->model('admin_model');
echo '3';
//$arr = $CI->admin_model->getAllDesigns();
echo '4';
$this->assertTrue(true);
echo '5';
}
}

$test = & new admin_model_test();
$test->run(new HtmlReporter());

?&gt;

Currently, the "&get;_instance()" is returning the default_controller class (Home Class). How can I get it to return the CI base class, and then call a ($CI->load->model(...)) on it?


  How to run CI in subdirectory?
Posted by: El Forum - 10-30-2007, 10:05 PM - Replies (3)

[eluser]Unknown[/eluser]
Hi, everybody:

I've met a problem. I installed the CI in a subdirectory on my web server. The directory structure listed below

http://domainname/
http://domainname/admin/

The path "/admin/" is a real directory in my filesystem and related to webroot dir, like this:

/domainname <- my webroot dir.
/domainname/admin/ <- CI installed path

I put .htaccess in CI installed path:

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /admin/
    RewriteCond %{REQUEST_FILENAME} !-F
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

My ci config is:
Code:
$config['base_url']    = "http://domainname/admin/"
$config['index_page'] = "";

I could run "http://domainname/admin/" but couldn't run controller like "http://domainname/admin/profile/changepw/".

I don't know how to make it work.


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
Error / Shield 1.0.3 + Ci...
by kcs
12 minutes ago
Is it possible to go back...
by ejimenezo
21 minutes ago
SQL server connection not...
by davis.lasis
35 minutes ago
Validation | trim causes ...
by Gary
2 hours ago
Problem with session hand...
by Julesb
3 hours ago
External script access to...
by PomaryLinea
3 hours ago
VIRUS reported after Chro...
by InsiteFX
8 hours ago
Codeigniter4 version 4.5....
by kenjis
Yesterday, 04:10 PM
Cannot access protected p...
by xsPurX
Yesterday, 02:10 PM
Update to v4.5.1, same us...
by xsPurX
Yesterday, 08:31 AM

Forum Statistics
» Members: 85,472
» Latest member: betvnddev
» Forum threads: 77,583
» Forum posts: 376,017

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB