Welcome Guest, Not a member yet? Register   Sign In
  Active Record gotcha
Posted by: El Forum - 10-22-2007, 09:13 AM - No Replies

[eluser]Michael Ekoka[/eluser]
in the following code I want to update the password field in one record :

Code:
$form_data = $this->input->post('form_data');

// I get my input from a form
$user_id = $form_data['user_id'];
$password = md5($form_data['password']);

$this->db->where('id',$id);
// notice the mistake I just made: instead of $user_id, I used $id that has not yet been
// initialized or declared.

$this->db->update('users',array('password'=>$password));

What I will end up doing here is update the password field of all records in the table. So, fellow CodeIgniters beware when making update and delete operations like these.


  Code Igniter Session problem
Posted by: El Forum - 10-22-2007, 08:29 AM - Replies (41)

[eluser]Unknown[/eluser]
Hello

i've tried to use code igniter session library and used ci_session table for added security. so far it was working perfectly in my local machine both IE and firefox. but as soon i have uploaded that in to my client server (php 5) ; i saw that the site is running in Mozilla firefox perfectly but
if i run the site in Internet Explorer(IE), then the site couldnt save the session data.

what is the problem any suggessions?


  Selecting one value from database?
Posted by: El Forum - 10-22-2007, 08:06 AM - Replies (6)

[eluser]fancms[/eluser]
I need to select one value from one row in the database. With the database class I used previously before finding CI I could accomplish this by doing

Code:
$variable = $db->get_var("SELECT somevalue FROM sometable WHERE something='therowvalue'");

This would allow me to use $variable as-is throughout my code.

I've been trying to figure out how to do this (select one value from a table) in CI. Right now I have

Code:
$this->db->select('value'); #Because I need the value
$this->db->where('variable', 'siteoverview'); #Because I need the variable column entitled siteoverview
$grab_cache = $this->db->get("settings"); #From the settings table

This produces
Code:
CI_DB_mysql_result Object
(
    [conn_id] => Resource id #27
    [result_id] => Resource id #31
    [result_array] => Array
        (
        )

    [result_object] => Array
        (
        )

    [current_row] => 0
    [num_rows] => 1
)

I'm a bit lost here. I haven't been able to find my answer in the docs, the forums, or the wiki. I know this is a basic question (and I'll likely feel pretty dumb when I find/get the answer) but I'm hoping someone will be kind enough to clarify a bit.

Thanks! Smile


  INSERT problem -> unknown column... [SOLVED]
Posted by: El Forum - 10-22-2007, 07:02 AM - Replies (1)

[eluser]victor76[/eluser]
Hi,

I got his blog post form in my View dir:

Code:
<form name="postit" action="http://localhost/codeIgniter/index.php/blog_controller/dopost" method="post">
    title: &lt;input type="text" name="title" id="title" /&gt;<br />
    comment: &lt;input type="text" name="comment" id="comment" /&gt;<br />
    &lt;input type="submit" value="send" /&gt;
&lt;/form&gt;

In my Controller I have:
Code:
function doPost()
        {
            $this->load->model('Blogmodel','',TRUE);
            
            $data['query'] = $this->Blogmodel->insert_entry();
            
        }

..And in my Model:
Code:
function insert_entry()
    {

    $this->title   = $_POST['title'];
        $this->content = $_POST['comment'];
        $this->date    = time();

        $this->db->insert('entries', $this);

    }

When I post my form, I get the error:
Quote:Error Number: 1054

Unknown column '_parent_name' in 'field list'

INSERT INTO entries (title, content, date, _parent_name, _ci_scaffolding, _ci_scaff_table) VALUES ('aaa', 'bla', 1193057963, 'Blogmodel', 0, 0)

...so, as a Newbie I can see i miss some columns in my DB (_parent_name, etc), but how can I fix my code so that it just inserts 'title','comment' and 'date'?

Best regards,
Vic


======================

I found it allready:
perhaps usefull for others...

Code:
function insert_entry()
    {
    $title   = $_POST['title'];
        $comment = $_POST['comment'];
    $aData = array('title' => $title, 'content' => $comment);
    $this->db->insert('entries', $aData);

    }

Is this the best way to insert data from a form, or is there a better way?
Best regards,

Vic


  CodeIgniter and PayPal IPN
Posted by: El Forum - 10-22-2007, 06:52 AM - Replies (6)

[eluser]Jatinder Thind[/eluser]
Hello,

I implemented a CI based E-Commerce site some months back. It uses PayPal for payment processing. I also setup a IPN (Instant Payment Notification) script for managing sales orders.

Although the IPN script works fine most of the time, it sometimes marks some of the IPN posts as invalid.

After a lot of research, I figured out that maybe the CI's Input library was modifying the POST variables so as to make them unusable for PayPal IPN.

Anyone else faced the same problem? Is there someway to skip Input library modifications during runtime?

Thanks,
Jatinder Thind


  404 Object Not Found
Posted by: El Forum - 10-22-2007, 06:36 AM - Replies (1)

[eluser]mikhailt[/eluser]
I get an error "404 Object Not Found"
in http://localhost/codeigniter/index.php/welcome

I have configured
$config['uri_protocol'] = "PATH_INFO";
and tried all the other combinations AUTO,QUERY_STRING etc.
Tried $config['index_page'] = "index.php?"; with ? or without '?' too
Default route is not configured.

If I try just http://localhost/codeigniter/index.php [no welcome here]
then got error "Unable to determine what should be displayed" as it should be.

If the default route is configured the start page is loaded. But further segmented URLs do not work. http://localhost/codeigniter/index.php/w.../my_method
I get an error "404 Object Not Found" Sad

I use the last CI 1.5.4 and IIS5.1 (Win XP) with proxy. But proxy is disabled in browser for localhost.

Can somebody help my?


  [resolved]Function in controller
Posted by: El Forum - 10-22-2007, 06:25 AM - Replies (9)

[eluser]isabelle[/eluser]
Hy everybody,

On my way to learn code igniter and the mvc coding, i have my really first problem.

I don't paste the model, but this one gets the datas of a website.
In that datas there are the tags, the keywords in fact. (example: http://leweb2.be/Mandellia.html)
These ones are separated by commas and i need to explode them via a function made for that.
I tried to define it in the controller but when i call that function in the view, i have that error:

Code:
Fatal error: Call to undefined function explode_term() in C:\wamp\www\eclipse\annuaire\system\application\views\fiche_view.php on line 56

Is that the moment when i need to create my own libraries?

Thanks in advance for your help,

CONTROLLER

Code:
class Fiche extends Controller{
        function fiche(){
            parent::Controller();
            $this->load->helper('url', 'database');
        }
        function index(){
            $id_website=$this->uri->segment(3);
            
            $this->load->model('fiche_model');
            $data['query']=$this->fiche_model->get_fiche($id_website);
            
            $this->load->view('fiche_view', $data);
        }
        
        function explode_term($terms){
            $list = explode(",", $terms);
            echo count($list);
        }    
    }

VIEW
Code:
&lt;?php
        foreach($query->result() as $row):
            echo '<h1>'.$row->app_name.'</h1>';
            echo '<p><span class="pink">Description :'.$row->app_short_description.'</span><br /><br />';
            echo '<span class="pink">Url :</span> <a href="'.$row->app_url.'" title="'.$row->app_short_description.'">'.$row->app_url.'</a><br /><br />';
            echo '<span class="pink">Description :</span><small>'.$row->app_description.'</small></p><br />';
            echo '<small><span class="pink">Mots-clé :</span><a href="" title="">'.explode_term($row->tags);'</a> |</small></div>';
        endforeach;
    ?&gt;


  Database class odity/bug
Posted by: El Forum - 10-22-2007, 04:51 AM - No Replies

[eluser]MyBelovedPHP[/eluser]
Seems that you can't do:

Code:
$sql = "SELECT *,lpad(id,8,'0') as id2 from table ORDER BY id2 DESC";
$query = $this->db->query($sql);
foreach ($query->result() as $row){

Just a white screen, no output at all, my controller simply ends.
The Select *, lpad(id,8,'0') as id2 seems to be the problem, when looping the foreach.

If I write out all column names (no *), i don't experience a problem.

The query is proper SQL though and will run everywhere, but not in CI.
Must be a bug somewhere in $query->result() as $row
FYI: I use it in a model class.
Can anyone confirm?

Debug shows:
DEBUG - 2007-10-22 12:47:33 (mem: 274.47) --&gt; Config Class Initialized
DEBUG - 2007-10-22 12:47:33 (mem: 274.16) --&gt; Hooks Class Initialized
DEBUG - 2007-10-22 12:47:33 (mem: 383.11) --&gt; No URI present. Default controller set.
DEBUG - 2007-10-22 12:47:33 (mem: 383.20) --&gt; Router Class Initialized
DEBUG - 2007-10-22 12:47:33 (mem: 446.55) --&gt; Output Class Initialized
DEBUG - 2007-10-22 12:47:33 (mem: 601.65) --&gt; Input Class Initialized
DEBUG - 2007-10-22 12:47:33 (mem: 603.51) --&gt; Global POST and COOKIE data sanitized
DEBUG - 2007-10-22 12:47:33 (mem: 650.05) --&gt; URI Class Initialized
DEBUG - 2007-10-22 12:47:33 (mem: 671.36) --&gt; Language Class Initialized
DEBUG - 2007-10-22 12:47:33 (mem: 930.20) --&gt; Loader Class Initialized
DEBUG - 2007-10-22 12:47:33 (mem: 1,438.46) --&gt; Database Driver Class Initialized
DEBUG - 2007-10-22 12:47:33 (mem: 1,437.66) --&gt; Controller Class Initialized
DEBUG - 2007-10-22 12:47:33 (mem: 1,527.48) --&gt; Helpers loaded: url
DEBUG - 2007-10-22 12:47:33 (mem: 1,635.26) --&gt; Model Class Initialized
DEBUG - 2007-10-22 12:47:34 (mem: 274.40) --&gt; Config Class Initialized
DEBUG - 2007-10-22 12:47:34 (mem: 274.23) --&gt; Hooks Class Initialized
DEBUG - 2007-10-22 12:47:34 (mem: 383.11) --&gt; No URI present. Default controller set.
DEBUG - 2007-10-22 12:47:34 (mem: 383.20) --&gt; Router Class Initialized
DEBUG - 2007-10-22 12:47:34 (mem: 446.55) --&gt; Output Class Initialized
DEBUG - 2007-10-22 12:47:34 (mem: 601.65) --&gt; Input Class Initialized
DEBUG - 2007-10-22 12:47:34 (mem: 603.51) --&gt; Global POST and COOKIE data sanitized
DEBUG - 2007-10-22 12:47:34 (mem: 650.05) --&gt; URI Class Initialized
DEBUG - 2007-10-22 12:47:34 (mem: 671.36) --&gt; Language Class Initialized
DEBUG - 2007-10-22 12:47:34 (mem: 930.20) --&gt; Loader Class Initialized
DEBUG - 2007-10-22 12:47:34 (mem: 1,438.46) --&gt; Database Driver Class Initialized
DEBUG - 2007-10-22 12:47:34 (mem: 1,437.66) --&gt; Controller Class Initialized
DEBUG - 2007-10-22 12:47:34 (mem: 1,527.48) --&gt; Helpers loaded: url
DEBUG - 2007-10-22 12:47:34 (mem: 1,635.26) --&gt; Model Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 274.40) --&gt; Config Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 274.23) --&gt; Hooks Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 383.11) --&gt; No URI present. Default controller set.
DEBUG - 2007-10-22 12:47:35 (mem: 383.20) --&gt; Router Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 446.55) --&gt; Output Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 601.65) --&gt; Input Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 603.51) --&gt; Global POST and COOKIE data sanitized
DEBUG - 2007-10-22 12:47:35 (mem: 650.05) --&gt; URI Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 671.36) --&gt; Language Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 930.20) --&gt; Loader Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 1,438.46) --&gt; Database Driver Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 1,437.66) --&gt; Controller Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 1,527.48) --&gt; Helpers loaded: url
DEBUG - 2007-10-22 12:47:35 (mem: 1,635.26) --&gt; Model Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 274.41) --&gt; Config Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 274.24) --&gt; Hooks Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 383.13) --&gt; No URI present. Default controller set.
DEBUG - 2007-10-22 12:47:35 (mem: 383.22) --&gt; Router Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 446.56) --&gt; Output Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 601.66) --&gt; Input Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 603.52) --&gt; Global POST and COOKIE data sanitized
DEBUG - 2007-10-22 12:47:35 (mem: 650.06) --&gt; URI Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 671.38) --&gt; Language Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 930.22) --&gt; Loader Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 1,438.48) --&gt; Database Driver Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 1,437.68) --&gt; Controller Class Initialized
DEBUG - 2007-10-22 12:47:35 (mem: 1,527.50) --&gt; Helpers loaded: url
DEBUG - 2007-10-22 12:47:35 (mem: 1,635.27) --&gt; Model Class Initialized
DEBUG - 2007-10-22 12:47:36 (mem: 274.41) --&gt; Config Class Initialized
DEBUG - 2007-10-22 12:47:36 (mem: 274.24) --&gt; Hooks Class Initialized
DEBUG - 2007-10-22 12:47:36 (mem: 383.13) --&gt; No URI present. Default controller set.
DEBUG - 2007-10-22 12:47:36 (mem: 383.22) --&gt; Router Class Initialized
DEBUG - 2007-10-22 12:47:36 (mem: 446.56) --&gt; Output Class Initialized
DEBUG - 2007-10-22 12:47:36 (mem: 601.66) --&gt; Input Class Initialized
DEBUG - 2007-10-22 12:47:36 (mem: 603.52) --&gt; Global POST and COOKIE data sanitized
DEBUG - 2007-10-22 12:47:36 (mem: 650.06) --&gt; URI Class Initialized
DEBUG - 2007-10-22 12:47:36 (mem: 671.38) --&gt; Language Class Initialized
DEBUG - 2007-10-22 12:47:36 (mem: 930.22) --&gt; Loader Class Initialized
DEBUG - 2007-10-22 12:47:36 (mem: 1,438.48) --&gt; Database Driver Class Initialized
DEBUG - 2007-10-22 12:47:36 (mem: 1,437.68) --&gt; Controller Class Initialized
DEBUG - 2007-10-22 12:47:36 (mem: 1,527.50) --&gt; Helpers loaded: url
DEBUG - 2007-10-22 12:47:36 (mem: 1,635.27) --&gt; Model Class Initialized
DEBUG - 2007-10-22 12:47:37 (mem: 274.43) --&gt; Config Class Initialized
DEBUG - 2007-10-22 12:47:37 (mem: 274.26) --&gt; Hooks Class Ini


  Image upload - temp dir not found?
Posted by: El Forum - 10-22-2007, 04:12 AM - Replies (1)

[eluser]#1313[/eluser]
Hi there.

I am uploading an image to my server. Everything works smoothly, until i decide to upload a big file (2+ mb). This gives me the really weird error from image_lib, something like this:

Code:
./tmp/ not found.

This obviously happened because of my max_upload_size variable, and i fix the problem by upping this limit from 2M to 4M in my php.ini. Okay, the big file uploads.

And then after a few hours i receive this error message again, this time with tiny 1.62mb image. My code is unchanged, and other smaller pictures are uploading correctly.

So, my two questions:
1. Isn't this "temp dir not found" message somewhat vague? I have a feeling that it says "Error! Go figure out what really happened by urself, lol".
2. What the heck is actually happening, lol?


  Validation
Posted by: El Forum - 10-22-2007, 03:49 AM - Replies (11)

[eluser]schnoodles[/eluser]
Hello i am currently building a usersystem and i am up to the part where you check to see if the username and password is correct. i was wondering if there is a proper way to throw errors for functions to make them look like it was a validation error.

So i could do like

Code:
if ( $validation->run() == true ) {
if ( !$user->exists ) { //do like a validation error }
else {

}
}

Anyone know what the best way to accomplish what i am trying to do is ?


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

Username
  

Password
  





Latest Threads
Table (view class) Row ID
by chenzen
2 hours ago
AbuseIPDB Module
by grimpirate
3 hours ago
curl + response body
by okatse
8 hours ago
tool bar not showing
by Luiz Marin
Today, 04:46 AM
Tool bar not showing
by Luiz Marin
Today, 04:28 AM
Heads up for users using ...
by davis.lasis
Yesterday, 12:54 PM
The Hidden Cost of “Innov...
by fcoder
Yesterday, 03:11 AM
Validation does not appea...
by grimpirate
07-01-2025, 01:55 PM
Block IP addresses of bad...
by grimpirate
07-01-2025, 01:47 PM
Override Router
by grimpirate
07-01-2025, 01:30 PM

Forum Statistics
» Members: 154,557
» Latest member: min88page
» Forum threads: 78,438
» Forum posts: 379,721

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB