Welcome Guest, Not a member yet? Register   Sign In
  DB Query issues
Posted by: El Forum - 08-21-2007, 04:03 PM - No Replies

[eluser]stevefink[/eluser]
Can anyone tell me why $photos in my view is not being seen by my view? I keep getting a notice that it is an undefined variable. I've made sure $photos is being populated properly in the model/controller:

Here's my controller:

Code:
function get_photos()
    {
        // get all photo filesystem locations.
        $photos = $this->autodb->get_photos();
        $this->load->view('console/vehicle_photos_view', $photos);
    }

My model:

Code:
function get_photos()
    {
        // return all available photos for vehicle
        $sql = "select photoloc from photos";
        $all_photos = $this->db->query($sql);
        
        $photos = array();
        
        if ($all_photos->num_rows() > 0)
        {
            foreach ($all_photos->result_array() as $photo)
            {
                $photos[] = $photo;
            }
        }
        
        return $photos;
    }

$photos is still undefined after $this->load->view('console/vehicle_photos_view', $photos);

Any idea?


  Session and headers sent problems :(
Posted by: El Forum - 08-21-2007, 02:14 PM - No Replies

[eluser]chobo[/eluser]
I'm trying to get my new version of my site to work, but I'm running into problems with headers and session. This probably has something to do with me being on a shared host because I never have these problems on my test computer.

I made my own session wrapper library, it's very simple and when I run the init() function to start the session, it triggers the "headers already sen" error. I'm not sure how to get my session to run before the server sends it's headers. Any help is appreciated, thanks

Code:
/*
    *    Check if session has been started and if header have been sent
    */
    private function init()
    {
        if (! isset($_SESSION))
        {
            if (headers_sent())
            {
                trigger_error ('Session was not started before headers sent');
            }
            else
            {
                session_start();
            }
        }
    }


  Validating HTML Input
Posted by: El Forum - 08-21-2007, 12:24 PM - No Replies

[eluser]DennisP[/eluser]
So I've been developing with CodeIgniter for about a month and a half now. I really like it so far. Smile

One thing that's kind of bugging me, is the lack of built in HTML validation. I don't mean XSS filtering and such, but just checking for closing HTML tags, stripping bad tags out, removing onmouseover="", etc.

Anyways, does anyone have any tips on how to do this? Is there a library someone has written to do this?

Thanks. Smile


  File uploads inquiry
Posted by: El Forum - 08-21-2007, 10:26 AM - No Replies

[eluser]stevefink[/eluser]
Hi all,

Hope everyone had a pleasant weekend.

I'm currently running an upload application based on SWFUpload, ( http://swfupload.mammon.se/ ) and I was curious how I can implement the native CI file upload handlers into my code. Currently I'm using something like this in my controller:

Code:
function upload()
    {
        if($_FILES) {
            set_time_limit(30); // This line sets the amount of time the script will execute for before it stops working. I've set this to 0 so there won't be any time-out errors.

            $uploadDir = "/Applications/MAMP/htdocs/f1auto_ci/uploads"; // Put in the directory that you will be uploading to. Don't forget the last '/'

            $filename = ereg_replace("[^A-Za-z0-9.]", "", $_FILES['Filedata']['name']); // Here I am taking the file name (accessed by $_FILES['Filedata']['name']) and I'm replacing any non alphanumeric characters. All that should be left is the file name, a dot and the extension.

            $uploadFile = $uploadDir . "/" . $filename; // This puts the directory and file name together in a variable. Handy for later on to keep your code easy to read.

            move_uploaded_file($_FILES['Filedata']['tmp_name'], $uploadFile); // This actually moves the file to the directory and file name specified by the $uploadFile variable.

            chmod($uploadFile, 0777); // Here I'm changing the permissions of the file so that we can do other things to it later on, like re-sizing images or being able to delete it from your FTP client.
            
            echo("This is complete!");
        }

Is it alright if I stick with this? The code is so customized, that I'm having difficulty incorporating it the CI way. I have a demo of this application up at http://devel.phpgeek.org/console/addvehicle/photos .. if you want to try to upload multiple files, they'll get deleted on the server right after. Just so you can get an idea of what I'm doing. :-)

Thanks,

- sf


  rapyd.com BUG!
Posted by: El Forum - 08-21-2007, 05:56 AM - No Replies

[eluser]MpaK69[/eluser]
Hello!

some little bug but strong
whe I came to rapyd.com site write error


Code:
An Error Was Encountered

Error, rapyd language not found: samples/rapyd/language/russian.php

it is ugly ^(

Iam from russia but cant to see that nice component!

Please, switch off this language detect


  Clean up my view
Posted by: El Forum - 08-21-2007, 04:57 AM - No Replies

[eluser]johnwbaxter[/eluser]
I would really like to get this sort of stuff out of my view

Code:
<?php foreach($con_options->result() as $item):?>
    <?$checkbox_value = $item->contact;?>
    &lt;?=form_checkbox('parent_contact[]', $checkbox_value, FALSE)?&gt;<label for ='&lt;?=$item->contact;?&gt;'>&lt;?=$item->contact;?&gt;</label><br />
    &lt;?php endforeach;?&gt;

and into a controller. I'm not averse to using the CI template syntax but i really cant figure out how to do it.

Any ideas?


  Call to undefined function: row_array()
Posted by: El Forum - 08-21-2007, 04:42 AM - No Replies

[eluser]Kemik[/eluser]
Hello,

I've used row_array() before so I'm not sure why it's giving an error

Code:
$this->db->select('user_name, email');
$this->db->where('user_id', $user_id);
$query = $this->db->from('users');
$data = $query->row_array();
                    
$data['message'] = '2';
$this->emailKickedUser($data);

Gives me:
Fatal error: Call to undefined function: row_array()

I have database in the autoload so it cannot be that. Other queries work fine. I just need to put the result in to the data array so it can be passed to the view and the email function.

Edit: Solved. I forgot the $this->db->get();

Thanks


  In a plugin I don't have access to database?
Posted by: El Forum - 08-21-2007, 04:25 AM - No Replies

[eluser]xcristi[/eluser]
Hello,

My problem is giving me headaches:
I have a plugin placed in application/plugins, called menu_pi.php. From this plugin I need to access my postgresql database. From a model I have no problem. But inside the plugin the code

$this->db->get('meniu'); doesn't work. So I think so, because my site get a blank screen.

My question: plugins cannot access database?

Thanks.
Cristian


  Load plugins into Libraries
Posted by: El Forum - 08-21-2007, 02:52 AM - No Replies

[eluser]Freakish_05[/eluser]
Hello everyone!

I've developed a simple view library that does all the repetative things of putting my header, footer, sidebar and 'view' files together.

I've also coded a plugin which creates my sidebar for me.

I'm trying to load this plugin into my 'view' library but its not having any of it.

Layout.php (view library)

Code:
&lt;?php
if(!defined('BASEPATH')) exit('No direct script access allowed!');

class Layout
{
    function Layout()
    {
        $this->layout =& get_instance();
    }
    
    function load_page($headerdata, $page, $data)
    {
        $this->load->plugin('sidebar');
        $sidebar = make_sidebar();
        $to_load = $this->layout->load->view('divided/header', $headerdata, true);
        $to_load .= $this->layout->load->view('divided/sidebar', $sidebar, true);
        $to_load .= $this->layout->load->view($page, $data, true);
        $to_load .= $this->layout->load->view('divided/footer', '', true);
        echo $to_load;
    }
}

The error message I'm getting is
Code:
Fatal error: Call to a member function plugin() on a non-object in D:\Webserver\htdocs\zomg\system\libraries\Layout.php on line 13
In short, its not liking the line $this->load->plugin('sidebar').

Is there a way to include this plugin into the library? If so, how do I do it? If not I'm assuming that I'll have to use the plugin in the controller and then pass the results back to the 'view' library.

Thanks in advance,
Freakish_05


  Using MVC
Posted by: El Forum - 08-21-2007, 02:38 AM - No Replies

[eluser]Paul Scott[/eluser]
Morning All,

I am just about to start playing about with CodeIgniter in a project I'm going to be working on. I'm going to see if I can get a good enough feel for it to use it and learn it on-the-fly.

My main worries about using CodeIgniter is that I struggle with sticking to the MVC structure (even though CodeIgniter is apparently not very strict about it) because I'm not quite sure how to work this.

I understand that Models are used for interaction with the database, Views are used for outputing the HTML and Controllers pull the page together. I'm not really sure how to port parts of my code, specifically classes that I have written (which, yes, interact with the database).

Lets say I'm using the following (mock) class:

Code:
class Member {

    var $id, $name, $email;

    function Member($id=NULL) {
        if ($id !== NULL)
            $this->load($id);
    }

    function load($id) {
        // ...
        $this->id = $r['id'];
        $this->name = $r['name'];
        $this->email = $r['email'];
    }

}

Before using MVC I would do the usual
Code:
$member = new Member($id);
and as far as my understanding goes the `Member` class should be a model because it's main function is to take things from the database. What's confusing me is that with CI I load models using `$this->load->model('member')`. So how would I change my class to work with the format `$member = new Member($id)`, assuming that I want to be able to use the CI database functions and having multiple instances of the `Member` object (this is why I think I should be using `new` over `$this->member`).

I've had a read around the forums and I believe what I'm looking for is
Code:
$this->CI =& get_instance(); // off the top of my head
but I'm looking for a little more insight into how what I'm wanting to do fits into the MVC workings.

Thanks,
Paul


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

Username
  

Password
  





Latest Threads
Update from 4.6.0 to 4.6....
by Vespa
5 hours ago
hot-reload side effects s...
by InsiteFX
8 hours ago
Changing Session cookie -...
by codeus
Yesterday, 03:19 PM
using app/Config/App.php ...
by sam547
05-16-2025, 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
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,665
» Latest member: tkvanphong
» Forum threads: 78,392
» Forum posts: 379,467

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB