Welcome Guest, Not a member yet? Register   Sign In
  error in using ODBC
Posted by: El Forum - 09-28-2008, 08:35 PM - Replies (1)

[eluser]kyko[/eluser]
I am having trouble fetching the data using System DSN and ODBC. When i try issuing a query, it works but when fetching the rows, i got this error message

Code:
Fatal error: Call to a member function result() on a non-object in D:\webroot\sqws\cfapp\controllers\welcome.php on line 21

The script generating the error

Code:
$this->db->like('field', 'JOE');
        $query2 = $this->db->get('database.table');
        foreach ($query2->result() as $row)
        {
           echo $row->field."<br />";
        }

Here's my config

Code:
$db['default']['hostname'] = "System";
$db['default']['username'] = "scrpt";
$db['default']['password'] = "ex0du5";
$db['default']['database'] = "";
$db['default']['dbdriver'] = "odbc";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

I might be forgetting something..?


  shopping cart and Paypal?
Posted by: El Forum - 09-28-2008, 07:28 PM - No Replies

[eluser]generalsalt[/eluser]
I have the task to build a e-commerce website that sells shirts. They want something where the customer can checkout without being directed to a gateway (Paypal etc..). They also want something to keep track of inventory.

I know there are monster frameworks like OS-Commerce and stuff like that..but this is actually I really small company (7 shirts for sale)..that seems a little overkill..maybe?

Does CI have any plugins / libraries that can deal with this sort of thing? Like, maybe a Paypal 'Direct Pay' plugin?

Please help!!!!! Smile


  building a list of categories
Posted by: El Forum - 09-28-2008, 05:43 PM - Replies (2)

[eluser]paulcj2[/eluser]
Building a list of categories, I am getting undefined variables in the views for my header and body of my category page.


My controller code includes:

Code:
$data = array(); //holds data for header, homepage & footer views
            $sql = "
            SELECT id, name, descrip_cat, keywords_cat, order_cat
            FROM category_products
            WHERE site_id = '" . SITE_ID . "'
            AND visible='Y'
            ORDER BY order_cat, name";
                
        $rs = $this->db->query($sql);
        foreach ($rs->result() as $row) {
            $prod_cat['id_cat'] = $row->id;
            $prod_cat['name_cat'] = $row->name;
            $prod_cat['descrip'] = $row->descrip_cat;
            $prod_cat['keywords'] = $row->keywords_cat;
            $prod_cat['order_cat'] = $row->order_cat;
            $prod_cat_results[] = $prod_cat;
            }
            $data['prod_cat_results'] = $prod_cat_results;
            $data['title'] = "Product categories";

        $this->load->view('page/header', $data);    
        $this->load->view('prod/cats_prod', $data);
        $this->load->view('page/footer');
My view code includes:
Code:
foreach ($prod_cat_results as $prod_cat) {
  echo "<h3><a href='/cat_prod/" . SITE_ADDRESS . "/$id_cat'>$name_cat</a></h3>";
  echo "<p>$descrip</p>";
  }

I suspect the problem is here
Code:
$prod_cat_results[] = $prod_cat;
            }
            $data['prod_cat_results'] = $prod_cat_results;
Any thoughts?


  Prefill forms from DB array
Posted by: El Forum - 09-28-2008, 04:10 PM - Replies (8)

[eluser]opel[/eluser]
Please could anyone tell me if it is possible or how to prefill a form view with data from my model and controller ?

What I have at the moment is :

Model :

Code:
function get($table, $id)
    {
        $query = $this->db->query("SELECT * FROM $table WHERE $id");
        $result =  $query->row();
    
        var_dump($result);
    
    }

Controller :

Code:
function edit($id){
        
        $data['pagetitle'] = 'Edit';
        
        //Select data based on ID
        $data['body'] = $this->Pages_model->Get('pages', $id);
        
        //write out data
        $this->template->write_view('content', 'pages/page_add', $data);
        
        //render
        $this->template->render();
        
    }

View :

Code:
<h1>&lt;?= $pagetitle; ?&gt;</h1>

&lt;?php

  $id = $this->uri->segment(3);

if($id == NULL){
  $id = 'X';
}




$form = array('name'=>'text','rows' => '10', 'cols' => '30');

$attributes = array('class' => 'email', 'id' => 'myform');

echo form_open('pages/form', $attributes); ?&gt;


&lt;?php echo $this->validation->error_string; ?&gt;

<table>
    <tr>
         <td><label><div align="right">Title : </div></label></td>
        <td>&lt;?= form_input('title'); ?&gt;</p></td>
    </tr>
    <tr>
             <td><label>Message : </label></td>
            <td colspan="2">&lt;?= form_textarea($form); ?&gt;</p></td>
    </tr>
    <tr>
             <td><label><div align="right">Order : </div></label></td>
            <td>&lt;?= form_input('order'); ?&gt;</p></td>
    </tr>
    <tr>
            <td>&nbsp;</td>
            <td>&lt;?= form_submit('submit', 'Add Page') ?&gt;</td>
    </tr>
    <tr>
            <td>&nbsp;</td>
            <td>&lt;?= form_hidden('id', $id) ?&gt;</td>
    </tr>
</table>
&lt;? echo form_close(); ?&gt;


  locking tables in database, is it needed?
Posted by: El Forum - 09-28-2008, 01:42 PM - Replies (4)

[eluser]Unknown[/eluser]
I'm sorry for my question, others more familiar with databases probably find it pretty trivial:

I have a many-to-many relationship (products, categories, productcategories) and when I update a specific product (flushing and adding new categories in the connector table as well) I think I really ought to do LOCK TABLES (which I indeed do, using LOCK TABLES with MySQL), but there's no such method in CI's ActiveRecord class - and transactions are not supported with MyIsam tables.

I have read most tutorials I could find in Google on locking tables and I still think I have to lock tables, though I might be wrong: what's the proper way to do it? I would like to be database agnostic in case I end up with a Postgres DB, which does have locking, but clearly states that it is not part of the SQL standard... any suggestions? Thanks!


  howto upload 3 files
Posted by: El Forum - 09-28-2008, 01:31 PM - Replies (3)

[eluser]Mitja[/eluser]
How to upload 3 files and validate each of them.


If i try like

Code:
if (!$this->upload->do_upload($field_name))
            {                
                $data['error_pdf1'] = $this->upload->display_errors('<div class="warning">', '</div>');    
                $this->load->view('admin/content_add', $data);
            }    
            else
            {  
                $uploads = $this->upload->data();
                        
                $data_insert = array(
                    'title' => $uploads['orig_name'] ,
                    'pdf_name' => $uploads['orig_name'] ,
                    'content_Id' => $new_id
                );
                      
                $this->db->insert('pdf', $data_insert);
            
            }  
            
            if (!$this->upload->do_upload('pdf2'))
            {                
                $data['error_pdf2'] = $this->upload->display_errors('<div class="warning">', '</div>');    
                $this->load->view('admin/content_add', $data);
            }    
            else
            {  
                $uploads = $this->upload->data();
                        
                $data_insert = array(
                    'title' => $uploads['orig_name'] ,
                    'pdf_name' => $uploads['orig_name'] ,
                    'content_Id' => $new_id
                );
                      
                $this->db->insert('pdf', $data_insert);
            }  
            
            if (!$this->upload->do_upload('pdf3'))
            {                
                $data['error_pdf3'] = $this->upload->display_errors('<div class="warning">', '</div>');    
                $this->load->view('admin/content_add', $data);
            }    
            else
            {  
                $uploads = $this->upload->data();
                        
                $data_insert = array(
                    'title' => $uploads['orig_name'] ,
                    'pdf_name' => $uploads['orig_name'] ,
                    'content_Id' => $new_id
                );
                      
                $this->db->insert('pdf', $data_insert);
            }

then i get 3 times page loeaded and not just once.


  SMTP Email on Windows Machine
Posted by: El Forum - 09-28-2008, 12:06 PM - Replies (4)

[eluser]Unknown[/eluser]
Hiya,

I would be very grateful if anybody could lend some advice on getting the Email class to run on a windows machine (normal WAMP thing) using the SMTP protocol. Many apologies if this is not the best section to make this request in. I've searched the forum and see that a few people have had time out issues when trying to use SMTP on windows boxes but didn't find any solution.

I'm experiencing a timeout issue on the second fgets (line 1610 on V1.6.3), after the EHLO is sent. I've extended it up to 120 to no avail. I've connected to the mail server via telnet and it's fine and nothing seems out of the ordinary. I was wondering if anybody could think of anything I maybe missing. Many thanks in advance.

Andy.


  Erkana Auth with password salt
Posted by: El Forum - 09-28-2008, 12:04 PM - No Replies

[eluser]ralf57[/eluser]
I've modified the Erkana Auth by adding a hardened password salt.
First the library:

Code:
class Auth {

    var $CI;

    function __construct()
    {
        $this->CI =& get_instance();
        log_message('debug', 'Authorization class initialized.');

        $this->CI->load->database();
    }


    function login($username, $password)
    {
        $this->CI->db->select('id, salt, password');
        
        $query = $this->CI->db->get_where('users', array('username'=>$username), 1, 0);
        
        if ($query->num_rows != 1)
        {
            return FALSE;
        }
        else
        {
            $row = $query->row();
            
            if ($this->check_password($password, $row->salt, $row->password))
            {
                $this->CI->session->set_userdata(array('user_id'=>$row->id));
                return TRUE;
            }
        }
    }
    
    function check_password($password, $salt, $hashed_pwd)
    {
        $this->CI->load->helper('security');
        
        if (dohash($password.$salt, 'sha1') === $hashed_pwd)
        {
            return TRUE;
        }
        else
        {
            return FALSE;  
        }
    }

    function logout()
    {
        $this->CI->session->set_userdata(array('user_id'=>FALSE));
    }


    function get_user($id)
    {
        if ($id)
        {
            $query = $this->CI->db->get_where('users', array('users.id'=>$id), 1, 0);
            
            if ($query->num_rows() == 1)
            {
                return $query->row();
            }
            else
            {
                return FALSE;
            }
        }
        else
        {
            return FALSE;
        }
    }
}

you will also need a table to store user data

Code:
CREATE TABLE IF NOT EXISTS `users` (
  `id` bigint(20) NOT NULL auto_increment,
  `username` varchar(60) collate utf8_unicode_ci NOT NULL,
  `password` varchar(60) collate utf8_unicode_ci NOT NULL,
  `email` varchar(100) collate utf8_unicode_ci NOT NULL,
  `created_on` timestamp NOT NULL default CURRENT_TIMESTAMP,
  `status` int(11) NOT NULL,
  `realname` varchar(250) collate utf8_unicode_ci NOT NULL,
  `salt` varchar(15) collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=2 ;

Please note the "salt" field which will hold each user's salt string

You will tipically use it in a callback function for your form validation

Code:
function check_login()
    {
        $username = $this->input->post('username');
        $password = $this->input->post('password');
        
        $this->auth->login($username, $password);
    }

Feel free to post suggestions and feedback
ral57


  if the upload field is empty i want continue.
Posted by: El Forum - 09-28-2008, 10:27 AM - Replies (4)

[eluser]Asinox[/eluser]
i want ask about upload field, and everything about upload...

i know that if the upload field is empty i get error message about it, but i want continue without file for upload.... how ill ignore the upload error if i dont hav file to upload?

thanks


  Blogmer First released!! - Open Source Blog
Posted by: El Forum - 09-28-2008, 09:55 AM - Replies (4)

[eluser]Yash[/eluser]
<h2>Blogmer -Open Source Blog System</h2>

We've released first beta version of Blogmer. :lol:

Speedovation.org is the official website of Blogmer, a light and Open Source PHP 4 and MySQL based blog package, distributed freely under the MIT license. Developed with simplicity and usability in mind, Blogmer is ideal for small to medium sized websites which need a clear and efficient blog package.

Direct download link : [url="http://speedovation.org/version/blog/Blogmer-1.0-Beta-First-Release.zip"]Download Blogmer[/url]

[url="http://speedovation.org/"]visit official site[/url]

May contain bugs/errors.Please report if you encounter one. :cheese:

Thank you


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

Username
  

Password
  





Latest Threads
Defining extra constants ...
by ramonpuig
16 minutes ago
Error / Shield 1.0.3 + Ci...
by kcs
2 hours ago
Bug with sessions CI 4.5....
by ALTITUDE_DEV
3 hours ago
Validation | trim causes ...
by kenjis
5 hours ago
Integrating Bootstrap 5 i...
by Bosborne
6 hours ago
Asset Minification Packag...
by tarcisiodev1
Yesterday, 05:11 PM
Modify users data as an a...
by luckmoshy
Yesterday, 04:56 PM
Is it possible to go back...
by ejimenezo
Yesterday, 11:49 AM
SQL server connection not...
by davis.lasis
Yesterday, 07:11 AM
Problem with session hand...
by Julesb
Yesterday, 04:13 AM

Forum Statistics
» Members: 85,558
» Latest member: sonamsharma4u
» Forum threads: 77,586
» Forum posts: 376,032

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB