Welcome Guest, Not a member yet? Register   Sign In
  [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.


  form_radio... set_radio from the database
Posted by: El Forum - 07-05-2008, 07:55 PM - No Replies

[eluser]EEssam[/eluser]
Hi,

I'm using the Validation class. I have something like this in my view:

Code:
Active <?php echo form_radio('status', '1', $this->validation->set_radio('status', '1')) ?>
Inactive <?php echo form_radio('status', '0', $this->validation->set_radio('status', '0')) ?>

This is an edit form, so it's working fine once the form is submitted. How can I have one of the options selected when the form is loaded for the first time?

Thanks.


  Posted X ago
Posted by: El Forum - 07-05-2008, 03:16 PM - Replies (9)

[eluser]stuffradio[/eluser]
Is there a helper that can give me this result? Say if I posted a comment, I want to be able to see Comment 12345 "posted 20 seconds ago."

Thanks!


  Routing and url_suffix
Posted by: El Forum - 07-05-2008, 02:38 PM - Replies (1)

[eluser]Roosevelt![/eluser]
Hello,
I am a little confused with this and hopefully someone can help me. I got both of working seperately but when I combine them, it dosn't work well.

In the routes.php file I have:

Code:
$route['games/(:num)'] = "welcome/games/$1";

In the config.php file I have:

Code:
$config['url_suffix'] = ".html";

So naturally if I visit http://www.test.com/games/1.html it should work but it doesn't.

But to test I tried http://www.test.com/welcome/games/1.html and it works just fine Smile.

Can you tell me how to get suffix working in this scenario.


  Selective Caching or.. Caching only a part of the output..
Posted by: El Forum - 07-05-2008, 02:11 PM - Replies (1)

[eluser]Unknown[/eluser]
Hey Guys,

I have a question.. I'm battling between using Smarty and using Code-Ignite.. yes I know they're very different but if I use Smarty I obviously won't be using Code-Ignite and vice versa..

Anyway I've read the features list and looked at the caching tutorial and there's one thing I'm missing - how do I cache only a small part of my page?

For example I have a header, footer, menu and content area and I would like to cache anything which isn't related to the members state - say the static footer and the semi-dynamic header (latest news but only changes once or twice a day) but I would not like to cache the menu (with it's "Hello {member_name}" and other member-related data)..

So what I'm asking if there's a way to control cache-ability of only certain views.

Thank you!
- Ben


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
26 minutes ago
Is it possible to go back...
by ejimenezo
34 minutes ago
SQL server connection not...
by davis.lasis
48 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
4 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