Welcome Guest, Not a member yet? Register   Sign In
  form validation - validation error before form submit
Posted by: El Forum - 10-21-2007, 03:22 PM - Replies (1)

[eluser]jahboite[/eluser]
I'm using the form helper and form validation, but I get differences on loading the page between my webserver at home (php5) and my hosted webserver php4.

Here's a snippet from my controller:

Code:
function index()
    {
        // load form helper
        $this->load->helper('form');
        $this->load->library('validation');
        
        // form validation
        $rules['dname'] = "trim|required|min_length[5]|max_length[255]|xss_clean";
        $rules['description'] = "trim|required|min_length[5]|max_length[1024]|xss_clean";
        $this->validation->set_error_delimiters('<p class="frm_valid_err">', '</p>');
        $this->validation->set_rules($rules);

        $fields['dname'] = 'DName';
        $fields['description'] = 'Description';
        $this->validation->set_fields($fields);

        if ($this->validation->run() == FALSE)
        {
            $page_data['page_title'] = 'View A';
            $this->load->view('a_vw',$page_data);
        }
        else
        {
            
            $page_data['page_title'] = 'View B';
            $this->load->view('b_vw',$page_data);
        }
    }
Here's a snippet from my view
Code:
&lt;?php
    echo $this->validation->error_string;
    
    $form_attributes = array('id' => 'form_id');
    $form_hidden = array('user_name' => getUnamefromUid($user), 'user_id' => $user);
    
    // form submits to self i.e. function index()
    echo form_open('',$form_attributes,$form_hidden);
    
    if ($this->validation->dname)
    {
        $dname_value = $this->validation->dname;
    }
    else
    {
        $dname_value = 'Type something here';
    }
    
    if ($this->validation->description)
    {
        $dscr_value = $this->validation->description;
    }
    else
    {
        $dscr_value = 'Type something here';
    }
        
    
    $text_name = array(
                  'name' => 'dname',
                  'id' => 'dname',
                  'value' => $dname_value,
                  'rows' => '2',
                  'cols' => '60',
                  'style' => 'width:100%',
                );
    
    $text_descr = array(
                  'name' => 'description',
                  'id' => 'description',
                  'value' => $dscr_value,
                  'rows' => '3',
                  'cols' => '60',
                  'style' => 'width:100%',
                );
    
    echo form_textarea($text_name);
    echo form_textarea($text_descr);
    echo '<br />'.form_submit('', 'Submit!');
    echo form_close();

?&gt;
There's another view (View B) which just echos "Success!".

On my webserver at home, I get the behaviour I expect.

On the hosted box, I get a "must have a value" validation error for both of the fields when I load View A, before I've even submitted the form.

Is this likely to be something to do with the version of php, my code, or the fact that the page is being rendered by facebook.


  Passing multiple variables on the URL
Posted by: El Forum - 10-21-2007, 02:12 PM - Replies (2)

[eluser]omed habib[/eluser]
I have the following URL:

www.mysite.com/shoppingcart/

And I want to pass variables to it such as:

www.mysite.com/shoppingcart/?newproduct=12&promotion=yes&shipping=same&etc=etc&etc=etc&etc=etc

However, I don't want to pass them as subdirectories because if they are NOT present, the function will return an error.

How do I pass multiple variables in the URL without having to define each variable as inputs to the function and if they are not present at all the function will still work?

Thanks!!


  Retrieving information from arrays
Posted by: El Forum - 10-21-2007, 12:56 PM - Replies (1)

[eluser]Robb__[/eluser]
I'm having trouble getting this to work.

Fist, I save information to theese arrays;

Code:
$data['Image'][$i] = $resultrow2[$i] ->Image; // {../Images/test.jpg, ../Images/test2.jpg, ../Images/test.jpg)
$data['Name'][$i] = $resultrow3[$i] ->productName; //{"one", "two", "three"]
$data['Price'][$i] = $resultrow4[$i] ->Price; // {10,20,30)
$data['Desc'][$i] = $resultrow5[$i] ->Description; // {"first one, second, third"}

Code:
$this->load->view('index',$data);

Then in my index.php I want to retrieve this information, but it doesn't work?

Code:
&lt;?php for ($i=0; $i&lt; $5; $i++): ?&gt;
<img src="&lt;?=${"Image$i"};?&gt;" onclick="showImage(&lt;?=${"Name$i"};?&gt;,&lt;?=${"Price$i"};?&gt;,'&lt;?=${"Desc$i"};?&gt;'); alt=""/&gt;</a>
&lt;?php endfor; ?&gt;


  Session lib
Posted by: El Forum - 10-21-2007, 12:28 PM - Replies (5)

[eluser]leonglass[/eluser]
I have a class that I have used before for managing sessions that makes use of phps session handling and using a db. I have been looking at CIs session class and have seen that the actual user data for the session is still stored in a cookie even when you set it to use the db. The class I have places the user data into a field in the db as name value pairs separated with semi-colons.

My questions are -
is the way CI does sessions better than the way I have been doing and if so why?
What do you all think of using my own class as a lib in CI does that make sense or not?

thanks


  SQL_CACH with CI DB active_record helpers
Posted by: El Forum - 10-21-2007, 12:23 PM - Replies (1)

[eluser]dreamynsx[/eluser]
okay so:

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

// Produces: SELECT * FROM mytable


Now, with Mysql query cache mechanism, type set to 2,
you can define which queries are to be inserted into the cache
by placing 'SQL_CACHE' right after the 'SELECT', like this:

$sql = "SELECT SQL_CACHE FROM mytable"

Does CI's active_record db helpers support this ability?

Or we have to build the query manually using the db->query like...
$this->db->query($sql);


  Filenaming question
Posted by: El Forum - 10-21-2007, 09:51 AM - Replies (2)

[eluser]Majd Taby[/eluser]
Hey, I keep having this problem over and over and I can't pinpoint it to exactly what it is.

My apps would work perfect on my local dev server (iMac on OS X), but when I move it to the shared folder and setup the configs, I get a bunch of "file was not found" I notice in the error though, the file names are not capitalized.

So what's the end-all be-all answer to this question?


  How to call a variable from other class
Posted by: El Forum - 10-21-2007, 08:57 AM - No Replies

[eluser]cinewbie81[/eluser]
Hi guys,

I have a file 'globalsetting.php' as following:

Code:
&lt;?php

class Globalsetting extends Controller {

    function Globalsetting()
    {    
        parent::Controller();
    }

    // Initialization function  
    function Initialize()
    {
           $DB1 = $this->load->database('MYDB1', TRUE);
           $DB2 = $this->load->database('myDB2', TRUE);
           $MyClient = "DELL";            
    }
}

My problem is:

How can i call variables DB1, DB2, and MyClient from other controller class ?? Anyone ? IS that correct that I put Globalsetting class extend from controller ? Hope someone can helkp as I'm stuck here for quite a while .. thanks in advance


  Language strings from Javascript
Posted by: El Forum - 10-21-2007, 07:49 AM - No Replies

[eluser]Unknown[/eluser]
I'm building an Arabic language app that has an embedded dynamic map in one of the views. The map I'm using is a customized ka-Map, which is basically an opensource Google map. I need to display language strings from within Javascript.

I'd like to use CodeIgniter's language files and avoid redefining the strings again. Any ideas on an elegant way to do this?

TIA


  Routing problem
Posted by: El Forum - 10-21-2007, 06:57 AM - Replies (1)

[eluser]hostingx[/eluser]
Hello people!

I'm working with the codeigniter custom version of Elliot Haughin, with the module system in it..

but i have a problem i cant solve!

I want to make several modules,

e.g: news, invoice, member etc..

all these modules need to have an admin, so i also made a module admin,

the module reads the menu's from the several modules.. but here is when i got stuck!

I want to use more then one controller in each module, 1 controller for the module: lets say news, and one for the admin panel for the module, lets say news_admin

But i can only call one controller, that should have the same name as the module, how can i change this?

here is my router file:

Code:
$exclude =     array(
                    '.',
                    '..',
                    'index.html',
                    'pages.php'
                );

    $handle = opendir(APPPATH.'modules/');
    
    while ( false !== ($file = readdir($handle)))
    {
        if ( !in_array($file, $exclude) )
        {
            if ( !is_dir(APPPATH.'modules/'.$file) )
            {
                $file = substr($file, 0, strlen($file) - 4);
            }
            
            $installed_modules[] = $file;
        }
    }
    
    //die(print_r($installed_modules));
    
    closedir($handle);
    
                        
foreach ($installed_modules as $module)
{
    // e.g. index.php/news
    
    $route[$module] = $module;
    
    // e.g. index.php/news/view/hello-me/
    
    $route[$module."/(.*)"] = $module."/$1";
    
}

hope you guys can help me out here!


  Where to place resources?
Posted by: El Forum - 10-21-2007, 04:57 AM - Replies (4)

[eluser]lszanto[/eluser]
This may sound dumb but I can't work out where I should place my images and stylesheets so that I can access them from the views file when the page is executed and complied.
Any help is appreciated and thanks in advance.


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

Username
  

Password
  





Latest Threads
hot-reload side effects s...
by PaulC
2 hours ago
Changing Session cookie -...
by codeus
4 hours ago
using app/Config/App.php ...
by sam547
Yesterday, 03:04 PM
Setting baseURL in Regist...
by grimpirate
05-15-2025, 02:20 PM
CRUD Code Generator
by DeanE10
05-15-2025, 05:31 AM
CodeIgniter.com - Report ...
by Harry Lyre
05-14-2025, 04:26 AM
Missing closing bracket w...
by abf
05-13-2025, 07:27 PM
Update from 4.6.0 to 4.6....
by FlavioSuar
05-13-2025, 04:17 AM
Sessions old files are de...
by InsiteFX
05-12-2025, 10:30 PM
Ajax post failing with Ty...
by PaulC
05-12-2025, 12:23 AM

Forum Statistics
» Members: 146,520
» Latest member: 1gomsocial
» Forum threads: 78,392
» Forum posts: 379,463

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB