Welcome Guest, Not a member yet? Register   Sign In
  update('value', 'value' + 1)
Posted by: El Forum - 09-12-2008, 07:44 AM - Replies (8)

[eluser]eldiablo[/eluser]
hi,
i want to add one the a value in the db
this work in start mysql terms
mysql_query("UPDATE mytable SET `value`=`value`+50 WHERE `id`="$userId);

i have tried update('value', 'value' + 1) and various other variations
and that doesn't work
anyone have any suggestions

thanks


  Need design advice for generating PDF files
Posted by: El Forum - 09-12-2008, 07:18 AM - Replies (1)

[eluser]Unknown[/eluser]
I'm building an app to generate certificates for students who complete training classes. The current app that's being replaced does this using Javascript + HTML; I'd like to do it with CodeIgniter + PDF using the FPDF library. I already have a nice modular MVC design that accesses a (makeshift) database, gets the data needed for the certificate, and prints it to the screen. Now I need to turn that into PDF functionality.

My questions are, is it reasonable to implement this PDF code in a file outside the controller, and if so how would you do it? I thought of putting the code in a view that doesn't actually display anything, then calling it with

Code:
$this->load->view( 'pdf_view', true );
but that seems to go against the principle of least astonishment.

This probably has an easy solution, but unfortunately I'm a nub. It'll certainly work whether the design is decoupled or not, but if it's possible I'd like to make it easy on the next person who reads this code. Thanks in advance for your help.


  Creating validation for a checkbox array.
Posted by: El Forum - 09-12-2008, 06:04 AM - Replies (3)

[eluser]Bramme[/eluser]
Okay, in my form I have a series of checkboxes called categories[] so I can process them as an array in my controller.

However, there's no validation for this in CI 1.6.3 (is there in 1.7? if so, i'm upgrading) so I thought I'd write my own.

Code:
$rules['categories[]'] = 'callback_required_checkbox';
That's in my controller

and in MY_Validation.php I have
Code:
function required_checkbox($str) {

    $ci =& get_instance();
    
    $ci->validation->set_message('require_array_checkbox', 'You have to set at least one checkbox');
        
    if( $ci->input->post($str) == '') {
        return FALSE;
    } else {
        return TRUE;
    }
}
However, nothing happens. I'd even be happy with an error message, but not even that! Unless I delete a ; offcourse. If I try to echo something in it, nothing happens either...

Can anybody help me out?


  Validation and file upload
Posted by: El Forum - 09-12-2008, 04:35 AM - Replies (8)

[eluser]dimis[/eluser]
I have done a validation rule for a form with CI validation.
Is there a way to put a file input as require?
Dimis


  Pagination configuration problems.
Posted by: El Forum - 09-12-2008, 04:00 AM - Replies (2)

[eluser]aquary[/eluser]
I'm new to CodeIgniter, but so far so good Yet there is a problem I can't solve here

I've read the user guide and know that I can put my pagination preference in config/pagination.php. But if I use it, how can I set the url, total rows, and data per page? They are all different in each page. I tried setting them before calling $this->pagination->create_links(), yet it didn't work since its configuration went to the preference file.

Any suggestion? Thank you Smile.


  Create folder in public_html: permission denied
Posted by: El Forum - 09-12-2008, 03:58 AM - Replies (2)

[eluser]mvdg27[/eluser]
Hi guys,

I have a question that's not directly CI related, but since there seem to be a lot of smart guys around here, I'll give it go!

The thing is this: I'm working on an install script for my CMS. This means the install script creates the database tables, some default entries and sets up a basic file structure.

The last part of it is now causing problems. Everytime I try to create files in the root of public_html, I get a message 'permission denied'. Off course, I understand what this message means and where it comes from. I'm just looking for a way to go around this ..

What I do now is create the top folder ('cms') myself through ftp (chmod it) and then run the script. This works, but doesn't seem ideal!

Is there some way to get this to work?

Thanks for thinking along with me!

Cheers, Michiel


  Prepopulating radio input
Posted by: El Forum - 09-12-2008, 03:22 AM - Replies (4)

[eluser]Bramme[/eluser]
Okay, I'm having a weird problem. Dunno where to go look for the solution though.

I'm building an edit form that has several inputs: textboxes, textareas, some checkboxes and a set of radio inputs.

Now I want to prepopulate the edit form, which works great for the text bits, but I can't get the radio buttons to prepopulate.

Code:
if( empty($this->validation->error_string)) {
    foreach ($fields as $field => $name) {
        $this->validation->$field = $data['tut'][$field];
    }
}
That's the code I use in my controller, it simply puts the values from the DB in if validation hasn't run yet.

Now I've changed the set_radio thingie (which doesn't work with prepopulated data, as it only looks at $_POST and not at $this->validation) with my own if:

Code:
<input type="radio" name="rankID" value="<?=$rank['rankID']?>" id="rank-<?=$rank['rankID']?>" <?php if($select_rank == $rank['rankID']) echo 'selected="selected" '; ?>/>

Now this works, I can see the selected="selected" code in my source code, it changes correctly when you submit the form but validation fails etc.

HOWEVER: it doesn't get selected in the form in the browser itself. Has anybody got any idea what could be causing this?


  Native session problem
Posted by: El Forum - 09-12-2008, 01:03 AM - Replies (1)

[eluser]dimis[/eluser]
I do a cms for a e-commerce site with native sessions of php (session_start()).
How can I configure the site to terminate a session after some time?
Yesterday I close my PC and today it was as I were already log on


  Vaidation Extension: Check DB for unique values
Posted by: El Forum - 09-11-2008, 08:41 PM - Replies (8)

[eluser]Scott Nelle[/eluser]
**
I've made a quick update to this code for the new form validation class (in CI 1.7.0.)
You can grab the update further down the page with a bit more detail at my website.
**

I didn't see anything like this posted yet, so I hope I'm not duplicating anything here. I've written a small extension to the validation library. It adds a rule called "unique" which accepts a parameter, the field name in the database that you're validating against.

I use it to check that usernames and email addresses are unique. There's a longer description at my website.

To use it, save it as system/application/libraries/MY_Validation.php. It will then load whenever you load the validation library.

Note: I've made some changes suggested in this thread and solved the issue where it expected a table called 'users'. The rule format has been updated to allow you to specify the table and column name. The rule format is now "unique[table.column]". For now I've left the error message in the library extension because CodeIgniter doesn't currently support extending language files, only completely replacing them. I'll probably pull it out eventually, but for now I want it to drop in as easily as possible. Non-english applications can, of course, alter the message.

Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* MY_Validation Class
*
* Extends Validation library
*
* Adds one validation rule, "unique" and accepts a
* parameter, the name of the table and column that
* you are checking, specified in the forum table.column  
*/
class MY_Validation extends CI_Validation {

    function My_Validation()
    {
        parent::CI_Validation();
    }

    // --------------------------------------------------------------------
    
    /**
     * Unique
     *
     * @access    public
     * @param    string
     * @param    field
     * @return    bool
     */    
    function unique($str, $field)
    {
        $CI =& get_instance();
        list($table, $column) = split("\.", $field, 2);
        
        $CI->validation->set_message('unique', 'The %s that you requested is unavailable.');
        
        $query = $CI->db->query("SELECT COUNT(*) dupe FROM $table WHERE $column = '$str'");
        $row = $query->row();
        return ($row->dupe > 0) ? FALSE : TRUE;
    }
}
?>


  Object error
Posted by: El Forum - 09-11-2008, 06:07 PM - Replies (9)

[eluser]stuffradio[/eluser]
For the life of me I can't figure out what's wrong.

Here is the code:

Code:
function artists()
  {
$data['logged_in'] = $this->loginlib->checkSession();
$data['error'] = "You're not an artist!";
$info = $this->users->getInfo();

    if (!$this->loginlib->checkSession())
    {
      $this->login();
    } else {

    $this->load->view('head', $data);
     if ($info->group <= 2)
    {
    $this->load->view('artists', $data);
    } else {
    $this->load->view('error', $data);
    }
    }
  }
Here is the error:
Quote:A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: controllers/home.php

Line Number: 72

Line in question: if ($info->group <= 2)


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

Username
  

Password
  





Latest Threads
Error / Shield 1.0.3 + Ci...
by kenjis
38 minutes ago
Integrating Bootstrap 5 i...
by tarcisiodev1
1 hour ago
Asset Minification Packag...
by tarcisiodev1
1 hour ago
Modify users data as an a...
by luckmoshy
2 hours ago
Is it possible to go back...
by ejimenezo
7 hours ago
SQL server connection not...
by davis.lasis
11 hours ago
Validation | trim causes ...
by Gary
Today, 05:09 AM
Problem with session hand...
by Julesb
Today, 04:13 AM
External script access to...
by PomaryLinea
Today, 03:58 AM
VIRUS reported after Chro...
by InsiteFX
Yesterday, 11:34 PM

Forum Statistics
» Members: 85,495
» Latest member: qh88lode
» Forum threads: 77,586
» Forum posts: 376,025

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB