Welcome Guest, Not a member yet? Register   Sign In
  Pagination display issue
Posted by: El Forum - 09-04-2007, 02:04 AM - No Replies

[eluser]E303[/eluser]
Hi all, first of all I would like to say that this is a great frame work to play with.

I am basically making a small blog app to play around with and I am having problems with the pagination side of things.

so far I have a model, which selects all the data in the mysql table in descending order. In my controller however I feel something is wrong because I have set the $config['per_page'] = '1'; yet all 4 posts are displayed on the blog page? The amount of links from the Pagination is correct just not the display..

any help would be greatly appreciated.


  passing language identificator via URL in multilingual site
Posted by: El Forum - 09-04-2007, 01:09 AM - No Replies

[eluser]El Oscuro[/eluser]
Hello everyone!

I try to create a bilingual site (English and Russian) and encounter the following problem:

My idea is to pass language identificator (eg "EN" or "RU") in URL, for example:

http://www.mysite.com/ru/news/1

I tried using Routes.php, here's what I have now in that file:

Code:
$route['^(en|ru)$'] = "{$route['default_controller']}/index/$1";
$route['(en|ru)/(.+?)/(.+)$'] = "$2/$3/$1";
$route['(en|ru)/(.+)$'] = "$2/index/$1";
But it simply says "Page not found" (CodeIgniter's message).

I have also tried to play with .htaccess file but it didn't get me too far as well.
Code:
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /codeIgniter/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?$1 [L]
</IfModule>
In other words all I want is that if "EN" or "RU" is found in the beginning or in the middle or the URL, it would just be ALWAYS transferred to the very end of it. Is it possible??

Does anybody have any ideas? Maybe someone faced similar problem...

P.S. I'm quite new to this kind of development and will appreciate any help!

Thanks in advance!


  Graceful error messages
Posted by: El Forum - 09-03-2007, 09:33 PM - No Replies

[eluser]stevefink[/eluser]
Folks,

Is there anyway I can do something to eliminate hard errors such as these for my application?


An Error Was Encountered

Error Number: 1062

Duplicate entry '123413421' for key 2

INSERT INTO vehicles (vin, stock, type, year, price, mileage, transmission, ext_color, int_color, body_style, doors, drive_train, engine, wheel_base, load_rating, notes, additional_opts, model_id, trim_id) VALUES ('123413421', '1234567', 'New', '2009', '', '', '', '', '', 0, 'null', 'null', '', '', '', '', '', '4', '18')


I'd much rather display something more user friendly to the non-tech type. I do realize I have to add sanity checking for duplies entries in my actual PHP, but where I miss these types of checks, what's my best bet?

- sf


  A couple of teething questions on the mechanics of embedding CI into one's website
Posted by: El Forum - 09-03-2007, 07:40 PM - No Replies

[eluser]buffalobill[/eluser]
Part One

I have a couple of specific beginner questions on the mechanics of how to embed the relevant parts (of the CI program into one's website, so that one can begin to follow the tutorials in a DIY manner (with the aim, of course, of learning to do more substantial stuff). First of all, I presume that there is no way that one can call up a CI PHP file on one's PC, rather than on one's website? (I note that the URI (actually URL, I reckon) listed in the text-only tutorial (TT), reflects a webaddress). I have tried to access, on my mirror-image "website" on my PC, the files I created while following the TT, but it just didn't work. Trying to mimic the webaddress URL, I wrote the following URI in MS Word (it became a link), then clicked on the link to see if it would take me to the target file (blog.php in this case) in the mirror-image folder of my website located on my PC (no luck, by the way):

file:///C:/mydomain/index.php/blog/ (if this were my website, the URI would read: http://www.mydomain/index.php/blog/).

I can easily access any HTML file on my old, non-PHP mirror-image "website" on my PC. In fact, I usually run through a new posting on my mirror site before uploading it, just to make sure that I didn't make any glaring mistakes, like incorrect linkages to image files.

Second problem: I reckon that the relevant part of the CI program to place on my website is the "system" folder, renaming "system" to reflect the name of my main (but not root) website folder, as suggested (I believe this to be the case, but I will return to this in a jiffy) in the index.php file of the "system"\application folder (when accessed with a text editor)? I have no doubt that it is not necessary for me to copy the "user-guide" folder to my website in order to follow the TT as long as I can post the relevant target files to my website where they can (presumably!) be accessed (more on this in a jiffy too), i.e., I can just run the tutorial from the mirror-image "website" on my PC, then check the newly-created, new-y-posted PHP file via my www website.

For what it's worth, my old website (cheapest hosting plan, no CGI-, no PHP support) had an unnamed root folder in which my main folder, i.e., the folder name I gave it, say, mainstreet, was located, and in which all of my files were located. There were no loose files at all in the unnamed root folder, only the subfolder (my main folder), mainstreet. The setup was like so: unnamed_root_folder\mainstreet (and with Stats and Images subfolders to mainstreet).

My new website (with a more advanced hosting plan), which does indeed support both CGI and PHP, is structured slightly differently. I still have a setup similar to the above, say, unnamed_root_folder\highstreet, but the main, or "index.html" file must be located, says the host, in the unnamed_root_folder. All I had to do to link to all the other files in the highstreet folder, of course, was to add "hightsteet" to the path of the next file in the sequence which the index.html file points to. Assume that the index.html file is a simple welcome page and when one clicks on the relevant field on the welcome page, one is redirected to the mainpage.html file. If this were my old site, I could just assign the href in the index.html file to "mainpage.html". With the new site, this must read: "highstreet/mainpage.html".

Part Two to be continued (I'll be back!)


  Loading resources within library
Posted by: El Forum - 09-03-2007, 07:29 PM - No Replies

[eluser]Code Arachn!d[/eluser]
Not sure if it's good or bad development standards - but I have several libraries that rely on other libraries (classes). Some make DB calls etc - so in my opinion it'd be good to be safe and load those libraries if not already loaded.

So I know the standard

Code:
$this->CI =& get_instance();

But my question is more along the lines that for the sake of performance that it'd make sense to just check if the resource is already loaded. Or is $this->CI->load->library() satisfactory to run this check - given the previous bugs in checking if class was already loaded.


  Parse error: syntax error, unexpected $end in ...
Posted by: El Forum - 09-03-2007, 07:14 PM - No Replies

[eluser]Reynolds[/eluser]
CI version 1.5.4

Code:
Parse error: syntax error, unexpected $end in /<hidden>/libraries/URI.php on line 63

in my local computer, it is NOT showing any error... but after uploading to zendurl.com this error shows up...

after checking it long enough, i found the problem...

at line 32 of the URI.php

Code:
var    $keyval    = array();

I changed it to
Code:
var    $keyval;

I reported this to ask if I just did right... I'm just a bit worrying if this might generate bug on the other part of CI (which relies on this variable).


thanks,


  Modified profiler to show session data
Posted by: El Forum - 09-03-2007, 07:10 PM - No Replies

[eluser]Nillian[/eluser]
Hey,

I've just downloaded OB Session (which is brilliant) and during my initial tinkering, I wanted the profiler to display the session data so I could keep track of what I was doing.

Now, just to warn you, it's a bit messy and I provide this with a "use at your own risk" warning! Smile

Currently, it will display the userdata, and session data separately, with their own headings under the fieldset 'SESSION DATA'. It also colours new and old flash data red and green respectively, so you can keep an eye on that. It also supports the native CodeIgniter session library, too, and will switch to a more basic view if it can't find OB Session (currently tested for by checking for the 'ro_userdata' method, which I realise is a bit of a bodged way of doing it, but hey, it works for my needs!)

Again, this was just for my purposes, just found it useful so I thought I'd upload it. Just drop the 'Profiler.php' file into your application/libraries folder and add the extra language-file lines to language/english/profiler_lang.php

I hope it works ok :-S

Direct file link: session_profiler.zip

Wiki Page: http://codeigniter.com/wiki/Session_Profiler/


  Multi-upload not working
Posted by: El Forum - 09-03-2007, 06:10 PM - No Replies

[eluser]RaZoR LeGaCy[/eluser]
can someone please look at my code and see where I am going wrong.

Controller:

Code:
$config['upload_path'] = './imgs/listings/'.$this->db->insert_id().'/';
$config['allowed_types'] = 'gif|jpg';
$config['overwrite']  = TRUE;
$config['max_size']    = '2048';
$config['max_width']  = '800';
$config['max_height']  = '600';
$config['remove_spaces']  = TRUE;

    
        $this->load->helper('file');

        $this->load->library('upload', $config);
        
        
mkdir($_SERVER['DOCUMENT_ROOT']."/imgs/listings/".$this->db->insert_id()."", 0777);

foreach($_FILES as $key => $value){
    if ( ! $this->upload->do_upload($key)){
        // do something here
} else {
$data = array($key => $this->upload->data());
}
}

View:
Code:
<table>
<tr>
    <td align="right" valign="top">Image #1:</td>
    <td colspan="2">&lt;input type="file" name="1" size="20" id="1" /&gt;</td>
    <td width="100" align="right">Image #2:</td>
    <td>&lt;input type="file" name="2" size="20" id="2" /&gt;</td>
</tr>
<tr>
  <td align="right" valign="top">Image #3:</td>
  <td colspan="2">&lt;input type="file" name="3" size="20" id="3" /&gt;</td>
  <td align="right">Image #4:</td>
  <td>&lt;input type="file" name="4" size="20" id="4" /&gt;</td>
</tr>
<tr>
  <td align="right" valign="top">Image #5:</td>
  <td colspan="2">&lt;input type="file" name="5" size="20" id="5" /&gt;</td>
  <td align="right">Image #6:</td>
  <td>&lt;input type="file" name="6" size="20" id="6" /&gt;</td>
</tr>
</table>

Thank you


  having trouble looping through query results
Posted by: El Forum - 09-03-2007, 05:37 PM - No Replies

[eluser]jvittetoe[/eluser]
Hello, in my application, once a user logs in they are directed to their dashboard controller...

Code:
&lt;?php

class Dashboard extends Controller {

    function Dashboard(){
        parent::Controller();
        $this->load->helper( array('url', 'form', 'date') );
        $this->load->library('validation');
        $this->load->model('userItems');
                
    }
    
    function index(){        
        $this->userItems->qryOverview();

        $data['title'] = "My Finance ~ v1.00 ~ Dashboard";
        $data['status'] = "PLEASE LOGIN";
        $data['query'] = $query;
        
        $template['mainContent'] = $this->load->view('dspDashboard', $data, true);
        $this->load->view('layDash', $template);
        
    }
}

from here i am loading the model, and running the function qryOverview which queries the db for all user items associated with the user. here is the qry.
Code:
function qryOverview(){
        
        $this->CI =& get_instance();
        //query db for current password
        /*
        $query = $this->db->select('*');
        $query = $this->db->from('user_items');
        $query = $this->db->where('user_id', $this->CI->session->userdata('id'));
        $query = $this->db->get();
        */
        $query = $this->db->query('SELECT * FROM user_items WHERE user_id = '.$this->CI->session->userdata("id").'');
        echo $query->num_rows();
        
        return $query;
        
    }
the query is returning the correct rows but i cant seem to figure out how to return the results back to the controller dashboard/index. any ideas.. thanks.


  routing problems
Posted by: El Forum - 09-03-2007, 05:03 PM - No Replies

[eluser]lefrog[/eluser]
I cannot seem to get my routing to work as per the user guide:

$route['page/:any'] = "page";

I want anything with the first segment equal to page and second segemnt equal to anything to go to page

It works if the url is:

http://localhost:9017/index.php/page/

but if I add a second segment i.e

http://localhost:9017/index.php/page/test/

I get a 404

Am I using the routes config correctly?


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

Username
  

Password
  





Latest Threads
Any user guid or video o...
by msnisha
5 hours ago
MVC vs MVCS vs CodeIgnite...
by massimiliano1.mancini
10 hours ago
Why PHP is still worth le...
by php_rocs
Today, 05:13 AM
Is hiring a digital marke...
by Markhenry123
Today, 02:45 AM
my controller fails to fi...
by PaulC
Today, 01:40 AM
My Library cannot see ses...
by InsiteFX
Yesterday, 08:48 PM
update the framework to t...
by captain-sensible
Yesterday, 12:14 PM
CodeIgniter Shield 1.0.0 ...
by Ayatorvi
Yesterday, 06:06 AM
Update to 4.6.1
by serialkiller
05-07-2025, 11:58 AM
Can't create new database...
by paulbalandan
05-07-2025, 08:49 AM

Forum Statistics
» Members: 144,988
» Latest member: sunwinepcom
» Forum threads: 78,382
» Forum posts: 379,420

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB