Welcome Guest, Not a member yet? Register   Sign In
  Generating Unique ID
Posted by: El Forum - 07-06-2008, 11:14 AM - Replies (15)

[eluser]Kemik[/eluser]
Hello,

I'm trying to generate a unique ID for a personal file upload script. I was looking for a 5 character string consisting of alphanumeric characters, both upper and lower.

Is there any way of making it truly unique? E.g. based off the current time or would that be too much hassle? If it isn't possible I was just going to use the below script and do a check in the database to make sure it hasn't already been used.

Code:
function createRandomPassword() {

    $chars = "abcdefghijkmnopqrstuvwxyz023456789";
    srand((double)microtime()*1000000);
    $i = 0;
    $pass = '' ;

    while ($i <= 5) {

        $num = rand() % 33;
        $tmp = substr($chars, $num, 1);
        $pass = $pass . $tmp;
        $i++;

    }
    return $pass;
}


  Cannot use output buffering in output buffering display handlers
Posted by: El Forum - 07-06-2008, 09:59 AM - Replies (7)

[eluser]Mitja[/eluser]

Quote:Fatal error: ob_start() [ref.outcontrol]: Cannot use output buffering in output buffering display handlers in C:\HTTPSERVER\wwwroot\bewoop\system\libraries\Exceptions.php on line 160

when i am trying to use

Code:
iconv_set_encoding("internal_encoding", "UTF-8");
iconv_set_encoding("output_encoding", "ISO-8859-2");
ob_start("ob_iconv_handler"); // start output buffering

how to fix that?


  SOLVED: Only show DB result from last month?
Posted by: El Forum - 07-06-2008, 06:34 AM - Replies (4)

[eluser]Joakim_[/eluser]
Hi.

I have some hard times showing only the last month entries from the DB.

Code:
$this->db->where('entry_date', date("m/d/Y",strtotime("last month")));

This code works but only show the entries with the same date as the current one. Somebody know how to make it show all entries from last month with any date? i have tried replacing the "d" and "Y" with "*" and even zeros but none of it work.


Any help are extremely appreciated! Thanks Smile


  Pagination and HTML Table
Posted by: El Forum - 07-06-2008, 05:52 AM - Replies (1)

[eluser]gregor4711[/eluser]
Hi,
I'm new in codigniter. Great Framework. Regards to the topic I have an understanding issue.

1. Sync the table class and the pagination class the required data by itself, or I have to pic up the page number and filter the result to show only the required data for the actual page with the limit function? Any example aviable for pagination and html table together?

2. I miss the function to change the displayed records per page (like ALL, 10, 20, 50)

Thanks for any help
Gregor


  [Solved] Cannot get model in 'Hello World' project to work - getting undefined variable notice
Posted by: El Forum - 07-06-2008, 04:07 AM - Replies (7)

[eluser]wild thing[/eluser]
Source Code

Am trying to make a simple blogging app following the user guide on CodeIgniter 1.6.3. However, I keep getting the following error:

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: posts

Filename: controllers/blahg.php

Line Number: 16

And the 'Failure' text is echoed, through my code. FYI, on line 26, $Posts_model doesn't work either (if I do $this->load->model('Posts_model');.

I've been pulling out my hair trying to figure out what I'm doing wrong. Help?


  .htacces, mod_rewrite check
Posted by: El Forum - 07-06-2008, 02:04 AM - Replies (6)

[eluser]Chicken's Egg[/eluser]
Is there a possibility to check whether or not a .htaccess-file is actually used? My .htaccess-file looks like:

Code:
RewriteEngine on

# Base URL
RewriteBase  /mysite/

# Options +FollowSymlinks
# Controleer of het geen bestaand directory is
RewriteCond %{REQUEST_FILENAME} !-d
# Controleer of het geen bestaand bestand is
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(index\.php|media|maatschappijleer|mysqladmin|usage|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

When I type the url http://localhost/mysite/index.php/news/ it works as expected, but http://localhost/mysite/news/ doesn't work. I got an Apache-error page. I tried it like this aswell:

Code:
RewriteRule ^news$ index.php/news/$1 [L]

But without result. In my Apache configuration file the mod_rewrite module is loaded:
LoadModule rewrite_module modules/mod_rewrite.so

I have used this .htaccess file successfully before, so I guess there is just something wrong with my Apache configuration.

Apache/2.0.63 (Win32)
PHP/5.2.6
Server at localhost Port 80


  Quick Question
Posted by: El Forum - 07-06-2008, 01:47 AM - Replies (1)

[eluser]Unknown[/eluser]
Hey there, downloaded CI about an hour ago and have been messing with it

Is there a way to set a 'default' function the same as __call() from php5? I tried but it wouldn't work. Basically is there a way to set a default function in the controller, but still have variables from the url, such as:

demo.com/user/Jack

Instead of calling a 'Jack' function, it'd call another one (say, User::ShowUser) and I'd be able to retrieve the name

The reason I ask is because having something like 'demo.com/user/profile/Jack' seems long. If there isn't a way I'll just go with that.


  callback not working
Posted by: El Forum - 07-05-2008, 10:11 PM - Replies (2)

[eluser]matches[/eluser]
Hello,

I am trying to get callback_ working but it doesn't seem to do anything. When I run this script it just goes straight to the insert statement. Currently I just want to echo my query when I call callback_ to make sure everything is working.

Thanks for any help.

Code:
function usernamecheck($str)
    {
        $this->db->select('userName');
        $this->db->where('userName', $str);
        $query = $this->db->get('users');
        echo $query;
        
        /*if ($str == $query)
        {
            $this->validation->set_message('username_check', 'The %s field can not be the word "test"');
            return FALSE;
        }
        else
        {
            return TRUE;
        }*/
    }
    
        
    function loadData()
    {        
        $userName = $this->input->post('userName');
        $email = $this->input->post('email');
        $password = $this->input->post('password');
        $passwordConfirm = $this->input->post('passwordConfirm');
        
        $rules['userName'] = "trim|required|callback_usernamecheck";
        $rules['password'] = "trim|required|matches[passconf]|md5";
        $rules['passconf'] = "trim|required";
        $rules['email'] = "trim|required|valid_email";
        
        $this->validation->set_rules($rules);
        
        $fields['username'] = 'Username';
        $fields['password'] = 'Password';
        $fields['passconf'] = 'Password Confirmation';
        $fields['email'] = 'Email Address';
        
        $this->validation->set_fields($fields);
        
        if ($this->validation->run() == FALSE)
        {
            $this->load->view('register/index');
        }
        else
        {
            $data = array(
                        'userName' => $this->input->post('userName'),
                        'password' => $this->input->post('password'),
                        'firstname' => $this->input->post('firstName'),
                        'lastName' => $this->input->post('lastName'),
                        'address1' => $this->input->post('address1'),
                        'address2' => $this->input->post('address2'),
                        'city' => $this->input->post('city'),
                        'state' => $this->input->post('state'),
                        'zip' => $this->input->post('zip'),
                        'email' => $this->input->post('email'),
                        'signUpDate' => now()
                        );
            $this->db->insert('users', $data);
            redirect("register/registered");
        }            
    }


  [Solved] Change password function
Posted by: El Forum - 07-05-2008, 09:06 PM - Replies (2)

[eluser]markanderson993[/eluser]
I am trying to write a script to allow the user to change their password. I have all of the required code down (check if certain fields are filled in yatta yatta). The part I am having grief over is checking weather or not the user's inputted current password matches that of their real current password in the database.

This is what I have. This code is the problematic portion. It is supposed to send back a TRUE/FALSE value depending on weather it found a match.

Problem is: I'm getting two errors
1. Undefined property: CI_DB_mysql_result::$hash
3. Undefined property: CI_DB_mysql_result::$password

Code:
//* check_password
        
        public function check_password($users, $current_password)
        {
            $username = $this->ci->session->userdata('username');
            $result = $this->ci->db->select('password','hash')->from($users)->where($users.'.username', $username)->get();
            $password = sha1($this->salt.$result->hash.$current_password); # New hashed password
            if ($password === $result->password)
            {
                return true;
            }
        
        }


  where to put database helpers (driver, active record, or helper)
Posted by: El Forum - 07-05-2008, 08:23 PM - Replies (4)

[eluser]a&w[/eluser]
I perused the mysqli_driver and DB_active_rec classes (as well as the user guide and forum of course).

I have repetitive needs to prepare a query with orderby, sortby and other where conditions. I wasn't quite sure where to stick these "helpers". Should I just make my own helper class, or extend either the driver or active record class?

My first impressions:

HELPER
pros: Don't "mess" with any core classes whatsoever
cons: Will need to load the helper class

ACTIVE RECORD
pros: Already available to model without loading
cons: I'm not sure the strings I'd generate would apply to other db drivers (but not likely use a different driver anyway)

MYSQLi DRIVER
pros: Already available to model without loading
cons: "Messing" with the core class, but if only adding methods shouldn't circumvent future CI releases?

So my inclination (at the moment) might be to extend the mysqli_driver.


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

Username
  

Password
  





Latest Threads
Codeigniter Shield Bannin...
by kenjis
21 minutes ago
SQL server connection not...
by kenjis
43 minutes ago
Best way to create micros...
by kenjis
2 hours ago
How to use Codeigniter wi...
by kenjis
2 hours ago
Getting supportedLocales ...
by kcs
8 hours ago
Component help
by FlashMaster
Today, 01:41 AM
Show logo in email inbox
by WiParson
Today, 12:48 AM
CI 4.5.1 CSRF - The actio...
by jackvaughn03
Yesterday, 10:17 PM
Limiting Stack Trace Erro...
by byrallier
Yesterday, 02:21 PM
Bug with sessions CI 4.5....
by ALTITUDE_DEV
Yesterday, 01:36 PM

Forum Statistics
» Members: 85,226
» Latest member: dewi188
» Forum threads: 77,577
» Forum posts: 375,977

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB